
<!doctype html>
<html lang="zh" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
        <meta name="description" content="一个自己的知识库网站，包含内容主要是嵌入式和图像处理相关，也有部分杂项内容。">
      
      
      
        <link rel="canonical" href="https://github.com/snqx-lqh/wiki/%E6%A0%91%E8%8E%93%E6%B4%BE%26%E5%9B%BD%E4%BA%A7%E6%B4%BE/%E6%A0%91%E8%8E%93%E6%B4%BE%E6%99%BA%E8%83%BD%E7%A1%AC%E4%BB%B6%E5%BC%80%E5%8F%91/12_Makefile/">
      
      
        <link rel="prev" href="../11_MQTT%E5%AE%9E%E9%AA%8C/">
      
      
        <link rel="next" href="../13_CSI%E6%91%84%E5%83%8F%E5%A4%B4%E4%BD%BF%E7%94%A8/">
      
      
      <link rel="icon" href="../../../assets/notebook.png">
      <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.5">
    
    
      
        <title>12 Makefile - LQH's Wiki</title>
      
    
    
      <link rel="stylesheet" href="../../../assets/stylesheets/main.8608ea7d.min.css">
      
        
        <link rel="stylesheet" href="../../../assets/stylesheets/palette.06af60db.min.css">
      
      


    
    
      
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
      <link rel="stylesheet" href="../../../stylesheets/my_scheme.css">
    
    <script>__md_scope=new URL("../../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
    
  <link rel="stylesheet" href="../../../assets/stylesheets/custom.7c86dd97.min.css">

   <link href="../../../assets/stylesheets/glightbox.min.css" rel="stylesheet"/><style>
    html.glightbox-open { overflow: initial; height: 100%; }
    .gslide-title { margin-top: 0px; user-select: text; }
    .gslide-desc { color: #666; user-select: text; }
    .gslide-image img { background: white; }
    .gscrollbar-fixer { padding-right: 15px; }
    .gdesc-inner { font-size: 0.75rem; }
    body[data-md-color-scheme="slate"] .gdesc-inner { background: var(--md-default-bg-color);}
    body[data-md-color-scheme="slate"] .gslide-title { color: var(--md-default-fg-color);}
    body[data-md-color-scheme="slate"] .gslide-desc { color: var(--md-default-fg-color);}</style> <script src="../../../assets/javascripts/glightbox.min.js"></script></head>
  
  
    
    
      
    
    
    
    
    <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo">
  
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#_1" class="md-skip">
          跳转至
        </a>
      
    </div>
    <div data-md-component="announce">
      
        <aside class="md-banner">
          <div class="md-banner__inner md-grid md-typeset">
            
              <button class="md-banner__button md-icon" aria-label="不再显示此消息">
                
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
              </button>
            
            
  For updates follow <strong>@squidfunk</strong> on
  <a rel="me" href="https://fosstodon.org/@squidfunk">
    <span class="twemoji mastodon">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M433 179.11c0-97.2-63.71-125.7-63.71-125.7-62.52-28.7-228.56-28.4-290.48 0 0 0-63.72 28.5-63.72 125.7 0 115.7-6.6 259.4 105.63 289.1 40.51 10.7 75.32 13 103.33 11.4 50.81-2.8 79.32-18.1 79.32-18.1l-1.7-36.9s-36.31 11.4-77.12 10.1c-40.41-1.4-83-4.4-89.63-54a102.5 102.5 0 0 1-.9-13.9c85.63 20.9 158.65 9.1 178.75 6.7 56.12-6.7 105-41.3 111.23-72.9 9.8-49.8 9-121.5 9-121.5m-75.12 125.2h-46.63v-114.2c0-49.7-64-51.6-64 6.9v62.5h-46.33V197c0-58.5-64-56.6-64-6.9v114.2H90.19c0-122.1-5.2-147.9 18.41-175 25.9-28.9 79.82-30.8 103.83 6.1l11.6 19.5 11.6-19.5c24.11-37.1 78.12-34.8 103.83-6.1 23.71 27.3 18.4 53 18.4 175z"/></svg>
    </span>
    <strong>Fosstodon</strong>
  </a>
  and
  <a href="https://x.com/squidfunk">
    <span class="twemoji twitter">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253"/></svg>
    </span>
    <strong>Twitter</strong>
  </a>

          </div>
          
            <script>var el=document.querySelector("[data-md-component=announce]");if(el){var content=el.querySelector(".md-typeset");__md_hash(content.innerHTML)===__md_get("__announce")&&(el.hidden=!0)}</script>
          
        </aside>
      
    </div>
    
    
      

  

<header class="md-header md-header--shadow md-header--lifted" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="页眉">
    <a href="../../.." title="LQH&#39;s Wiki" class="md-header__button md-logo" aria-label="LQH's Wiki" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 7V5h2V4a2 2 0 0 1 2-2h6v7l2.5-1.5L18 9V2h1c1.05 0 2 .95 2 2v16c0 1.05-.95 2-2 2H7c-1.05 0-2-.95-2-2v-1H3v-2h2v-4H3v-2h2V7zm4 4H5v2h2zm0-4V5H5v2zm0 12v-2H5v2z"/></svg>

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            LQH's Wiki
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              12 Makefile
            
          </span>
        </div>
      </div>
    </div>
    
      
        <form class="md-header__option" data-md-component="palette">
  
    
    
    
    <input class="md-option" data-md-color-media="(prefers-color-scheme)" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo"  aria-label="Switch to light mode"  type="radio" name="__palette" id="__palette_0">
    
      <label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m14.3 16-.7-2h-3.2l-.7 2H7.8L11 7h2l3.2 9zM20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zm-9.15 3.96h2.3L12 9z"/></svg>
      </label>
    
  
    
    
    
    <input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo"  aria-label="Switch to dark mode"  type="radio" name="__palette" id="__palette_1">
    
      <label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_2" hidden>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
      </label>
    
  
    
    
    
    <input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="indigo" data-md-color-accent="indigo"  aria-label="Switch to system preference"  type="radio" name="__palette" id="__palette_2">
    
      <label class="md-header__button md-icon" title="Switch to system preference" for="__palette_0" hidden>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
      </label>
    
  
</form>
      
    
    
      <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
    
    
    
      <label class="md-header__button md-icon" for="__search">
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
      </label>
      <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="搜索" placeholder="搜索" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256l137.3-137.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="查找">
        
          <a href="javascript:void(0)" class="md-search__icon md-icon" title="分享" aria-label="分享" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1">
            
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91s2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08"/></svg>
          </a>
        
        <button type="reset" class="md-search__icon md-icon" title="清空当前内容" aria-label="清空当前内容" tabindex="-1">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
        </button>
      </nav>
      
        <div class="md-search__suggest" data-md-component="search-suggest"></div>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            正在初始化搜索引擎
          </div>
          <ol class="md-search-result__list" role="presentation"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
    
    
      <div class="md-header__source">
        <a href="https://github.com/snqx-lqh/wiki" title="前往仓库" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
  </div>
  <div class="md-source__repository">
    snqx-lqh/wiki
  </div>
</a>
      </div>
    
  </nav>
  
    
      
<nav class="md-tabs" aria-label="标签" data-md-component="tabs">
  <div class="md-grid">
    <ul class="md-tabs__list">
      
        
  
  
  
    <li class="md-tabs__item">
      <a href="../../.." class="md-tabs__link">
        
  
    
  
  主页

      </a>
    </li>
  

      
        
  
  
  
    
    
      
  
  
  
    
    
      <li class="md-tabs__item">
        <a href="../../../%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86/Jetson/01_Jetson%20TX2%20NX%20%E6%9D%BF%E5%AD%90%E5%9F%BA%E6%9C%AC%E8%AE%BE%E7%BD%AE/" class="md-tabs__link">
          
  
    
  
  图像处理

        </a>
      </li>
    
  

    
  

      
        
  
  
  
    
    
      
  
  
  
    
    
      <li class="md-tabs__item">
        <a href="../../../%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/ESP32%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0/01.GPIO%E7%9A%84%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA/" class="md-tabs__link">
          
  
    
  
  嵌入式学习笔记

        </a>
      </li>
    
  

    
  

      
        
  
  
  
    
    
      
  
  
  
    
    
      <li class="md-tabs__item">
        <a href="../../../%E6%8A%98%E8%85%BE/Docker%E7%9B%B8%E5%85%B3/00.docker%E7%9A%84%E5%AE%89%E8%A3%85%E4%BB%A5%E5%8F%8A%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE%E4%BD%BF%E7%94%A8/" class="md-tabs__link">
          
  
    
  
  折腾

        </a>
      </li>
    
  

    
  

      
        
  
  
    
  
  
    
    
      <li class="md-tabs__item md-tabs__item--active">
        <a href="../../%E6%A0%91%E8%8E%93%E6%B4%BE%E5%85%A5%E9%97%A8/" class="md-tabs__link">
          
  
    
  
  树莓派&国产派

        </a>
      </li>
    
  

      
        
  
  
  
    
    
      
  
  
  
    
    
      <li class="md-tabs__item">
        <a href="../../../%E9%A1%B9%E7%9B%AE%E8%AE%BE%E8%AE%A1/00.51/%E5%9F%BA%E4%BA%8E51%E5%8D%95%E7%89%87%E6%9C%BA%E7%9A%84%E6%8E%A7%E5%88%B6%E5%9B%9B%E7%BA%BF%E6%AD%A5%E8%BF%9B%E7%94%B5%E6%9C%BA%E4%BB%BF%E7%9C%9F%E8%AE%BE%E8%AE%A1/" class="md-tabs__link">
          
  
    
  
  项目设计

        </a>
      </li>
    
  

    
  

      
    </ul>
  </div>
</nav>
    
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    


  


<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="导航栏" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../../.." title="LQH&#39;s Wiki" class="md-nav__button md-logo" aria-label="LQH's Wiki" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 7V5h2V4a2 2 0 0 1 2-2h6v7l2.5-1.5L18 9V2h1c1.05 0 2 .95 2 2v16c0 1.05-.95 2-2 2H7c-1.05 0-2-.95-2-2v-1H3v-2h2v-4H3v-2h2V7zm4 4H5v2h2zm0-4V5H5v2zm0 12v-2H5v2z"/></svg>

    </a>
    LQH's Wiki
  </label>
  
    <div class="md-nav__source">
      <a href="https://github.com/snqx-lqh/wiki" title="前往仓库" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
  </div>
  <div class="md-source__repository">
    snqx-lqh/wiki
  </div>
</a>
    </div>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../../.." class="md-nav__link">
        
  
  <span class="md-ellipsis">
    主页
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    
    
      
        
      
        
      
        
      
        
      
        
      
    
    
      
      
    
    
      
        
        
      
    
    <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
      
        
  
  
    
  
  
    <a href="../../../%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86/Jetson/01_Jetson%20TX2%20NX%20%E6%9D%BF%E5%AD%90%E5%9F%BA%E6%9C%AC%E8%AE%BE%E7%BD%AE/" class="md-nav__link">
      
  
  <span class="md-ellipsis">
    图像处理
    
  </span>
  

      
        <span class="md-nav__icon md-icon"></span>
      
    </a>
  

  

      
    </li>
  

    
      
      
  
  
  
  
    
    
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
    
    
      
      
    
    
      
        
        
      
    
    <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
      
        
  
  
    
  
  
    <a href="../../../%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/ESP32%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0/01.GPIO%E7%9A%84%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA/" class="md-nav__link">
      
  
  <span class="md-ellipsis">
    嵌入式学习笔记
    
  </span>
  

      
        <span class="md-nav__icon md-icon"></span>
      
    </a>
  

  

      
    </li>
  

    
      
      
  
  
  
  
    
    
      
        
      
        
      
        
      
        
      
    
    
      
      
    
    
      
        
        
      
    
    <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
      
        
  
  
    
  
  
    <a href="../../../%E6%8A%98%E8%85%BE/Docker%E7%9B%B8%E5%85%B3/00.docker%E7%9A%84%E5%AE%89%E8%A3%85%E4%BB%A5%E5%8F%8A%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE%E4%BD%BF%E7%94%A8/" class="md-nav__link">
      
  
  <span class="md-ellipsis">
    折腾
    
  </span>
  

      
        <span class="md-nav__icon md-icon"></span>
      
    </a>
  

  

      
    </li>
  

    
      
      
  
  
    
  
  
  
    
    
      
        
      
        
      
        
      
        
      
        
      
    
    
      
        
        
      
      
    
    
      
    
    <li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" checked>
        
          
          <label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="">
            
  
  <span class="md-ellipsis">
    树莓派&国产派
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="true">
          <label class="md-nav__title" for="__nav_5">
            <span class="md-nav__icon md-icon"></span>
            树莓派&国产派
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../%E6%A0%91%E8%8E%93%E6%B4%BE%E5%85%A5%E9%97%A8/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    树莓派入门
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    
    
      
        
      
    
    
      
      
    
    
      
        
        
      
    
    <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
      
        
  
  
    <a href="../../%E5%85%A8%E5%BF%97F1C200S%E5%BC%80%E5%8F%91/01_F1C200S%E7%9A%84Docker%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" class="md-nav__link">
      
  
  <span class="md-ellipsis">
    全志F1C200S开发
    
  </span>
  

      
        <span class="md-nav__icon md-icon"></span>
      
    </a>
  

      
    </li>
  

              
            
              
                
  
  
  
  
    
    
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
    
    
      
      
    
    
      
        
        
      
    
    <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
      
        
  
  
    <a href="../../%E6%A0%91%E8%8E%93%E6%B4%BE%E6%99%BA%E8%83%BD%E5%AE%B6%E5%B1%85%E9%A1%B9%E7%9B%AE/01_%E6%A0%91%E8%8E%93%E6%B4%BE%E7%9A%84%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%BD%95%E4%BB%A5%E5%8F%8A%E5%88%9D%E6%AC%A1%E5%BC%80%E6%9C%BA%E9%85%8D%E7%BD%AE/" class="md-nav__link">
      
  
  <span class="md-ellipsis">
    树莓派智能家居项目
    
  </span>
  

      
        <span class="md-nav__icon md-icon"></span>
      
    </a>
  

      
    </li>
  

              
            
              
                
  
  
    
  
  
  
    
    
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
    
    
      
      
    
    
      
    
    <li class="md-nav__item md-nav__item--active md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_4" checked>
        
          
          <label class="md-nav__link" for="__nav_5_4" id="__nav_5_4_label" tabindex="0">
            
  
  <span class="md-ellipsis">
    树莓派智能硬件开发
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="2" aria-labelledby="__nav_5_4_label" aria-expanded="true">
          <label class="md-nav__title" for="__nav_5_4">
            <span class="md-nav__icon md-icon"></span>
            树莓派智能硬件开发
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../01_%E6%A0%91%E8%8E%93%E6%B4%BE%E7%9A%84%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%BD%95%E4%BB%A5%E5%8F%8A%E5%88%9D%E6%AC%A1%E5%BC%80%E6%9C%BA%E9%85%8D%E7%BD%AE/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    01 树莓派的系统烧录以及初次开机配置
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../02_GPIO%E8%BE%93%E5%87%BA%E6%8E%A7%E5%88%B6/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    02 GPIO输出控制
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../03_GPIO%E8%BE%93%E5%85%A5%E6%A3%80%E6%B5%8B/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    03 GPIO输入检测
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../04_PWM%E8%BE%93%E5%87%BA/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    04 PWM输出
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../05_IIC%E5%AE%9E%E9%AA%8C/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    05 IIC实验
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../06_SPI%E5%AE%9E%E9%AA%8C/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    06 SPI实验
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../07_UART%E5%AE%9E%E9%AA%8C/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    07 UART实验
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../08_Tcp%E9%80%9A%E4%BF%A1/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    08 Tcp通信
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../09_UDP%E9%80%9A%E4%BF%A1/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    09 UDP通信
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../10_HTTP%E9%80%9A%E4%BF%A1/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    10 HTTP通信
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../11_MQTT%E5%AE%9E%E9%AA%8C/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    11 MQTT实验
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
    
  
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
      
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          
  
  <span class="md-ellipsis">
    12 Makefile
    
  </span>
  

          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="./" class="md-nav__link md-nav__link--active">
        
  
  <span class="md-ellipsis">
    12 Makefile
    
  </span>
  

      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#_1" class="md-nav__link">
    <span class="md-ellipsis">
      说明
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#makefile" class="md-nav__link">
    <span class="md-ellipsis">
      Makefile基础
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Makefile基础">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#_2" class="md-nav__link">
    <span class="md-ellipsis">
      最终目标
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_3" class="md-nav__link">
    <span class="md-ellipsis">
      伪目标
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_4" class="md-nav__link">
    <span class="md-ellipsis">
      依赖
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_5" class="md-nav__link">
    <span class="md-ellipsis">
      变量
    </span>
  </a>
  
    <nav class="md-nav" aria-label="变量">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#_6" class="md-nav__link">
    <span class="md-ellipsis">
      条件赋值
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_7" class="md-nav__link">
    <span class="md-ellipsis">
      追加赋值
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#shell" class="md-nav__link">
    <span class="md-ellipsis">
      shell运行赋值
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_8" class="md-nav__link">
    <span class="md-ellipsis">
      多行变量
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_9" class="md-nav__link">
    <span class="md-ellipsis">
      清楚变量
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_10" class="md-nav__link">
    <span class="md-ellipsis">
      环境变量的使用
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_11" class="md-nav__link">
    <span class="md-ellipsis">
      变量替换引用
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_12" class="md-nav__link">
    <span class="md-ellipsis">
      变量覆盖
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_13" class="md-nav__link">
    <span class="md-ellipsis">
      自动变量
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_14" class="md-nav__link">
    <span class="md-ellipsis">
      条件判断
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_15" class="md-nav__link">
    <span class="md-ellipsis">
      处理函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="处理函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#_16" class="md-nav__link">
    <span class="md-ellipsis">
      字符替换与分析
    </span>
  </a>
  
    <nav class="md-nav" aria-label="字符替换与分析">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#subst" class="md-nav__link">
    <span class="md-ellipsis">
      subst
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#strip" class="md-nav__link">
    <span class="md-ellipsis">
      strip
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#findstring" class="md-nav__link">
    <span class="md-ellipsis">
      findstring
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#filter" class="md-nav__link">
    <span class="md-ellipsis">
      filter
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#filter-out" class="md-nav__link">
    <span class="md-ellipsis">
      filter-out
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#sort" class="md-nav__link">
    <span class="md-ellipsis">
      sort
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#word" class="md-nav__link">
    <span class="md-ellipsis">
      word
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#wordlist" class="md-nav__link">
    <span class="md-ellipsis">
      wordlist
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#words" class="md-nav__link">
    <span class="md-ellipsis">
      words
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#firstword" class="md-nav__link">
    <span class="md-ellipsis">
      firstword
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#lastword" class="md-nav__link">
    <span class="md-ellipsis">
      lastword
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_17" class="md-nav__link">
    <span class="md-ellipsis">
      文件名处理函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="文件名处理函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#dir" class="md-nav__link">
    <span class="md-ellipsis">
      dir
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#notdir" class="md-nav__link">
    <span class="md-ellipsis">
      notdir
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#suffix" class="md-nav__link">
    <span class="md-ellipsis">
      suffix
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#basename" class="md-nav__link">
    <span class="md-ellipsis">
      basename
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#addsuffix" class="md-nav__link">
    <span class="md-ellipsis">
      addsuffix
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#addprefix" class="md-nav__link">
    <span class="md-ellipsis">
      addprefix
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#join" class="md-nav__link">
    <span class="md-ellipsis">
      join
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#wildcard" class="md-nav__link">
    <span class="md-ellipsis">
      wildcard
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#realpath" class="md-nav__link">
    <span class="md-ellipsis">
      realpath
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#abspath" class="md-nav__link">
    <span class="md-ellipsis">
      abspath
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_18" class="md-nav__link">
    <span class="md-ellipsis">
      条件函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="条件函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#if" class="md-nav__link">
    <span class="md-ellipsis">
      if
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#or" class="md-nav__link">
    <span class="md-ellipsis">
      or
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#and" class="md-nav__link">
    <span class="md-ellipsis">
      and
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#intcmp" class="md-nav__link">
    <span class="md-ellipsis">
      intcmp
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#file" class="md-nav__link">
    <span class="md-ellipsis">
      file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foreach" class="md-nav__link">
    <span class="md-ellipsis">
      foreach
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#call" class="md-nav__link">
    <span class="md-ellipsis">
      call
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#value" class="md-nav__link">
    <span class="md-ellipsis">
      value
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#origin" class="md-nav__link">
    <span class="md-ellipsis">
      origin
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#flavor" class="md-nav__link">
    <span class="md-ellipsis">
      flavor
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#eval" class="md-nav__link">
    <span class="md-ellipsis">
      eval
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#shell_1" class="md-nav__link">
    <span class="md-ellipsis">
      shell
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#let" class="md-nav__link">
    <span class="md-ellipsis">
      let
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_19" class="md-nav__link">
    <span class="md-ellipsis">
      信息提示函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="信息提示函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#error" class="md-nav__link">
    <span class="md-ellipsis">
      error
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#warning" class="md-nav__link">
    <span class="md-ellipsis">
      warning
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#info" class="md-nav__link">
    <span class="md-ellipsis">
      info
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_20" class="md-nav__link">
    <span class="md-ellipsis">
      
    </span>
  </a>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../13_CSI%E6%91%84%E5%83%8F%E5%A4%B4%E4%BD%BF%E7%94%A8/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    13 CSI摄像头使用
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

              
            
              
                
  
  
  
  
    
    
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
        
      
    
    
      
      
    
    
      
        
        
      
    
    <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
      
        
  
  
    <a href="../../%E6%A0%91%E8%8E%93%E6%B4%BE%E9%A9%B1%E5%8A%A8%E5%BC%80%E5%8F%91/00_%E9%A9%B1%E5%8A%A8%E5%BC%80%E5%8F%91%E6%80%BB%E8%A7%88/" class="md-nav__link">
      
  
  <span class="md-ellipsis">
    树莓派驱动开发
    
  </span>
  

      
        <span class="md-nav__icon md-icon"></span>
      
    </a>
  

      
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
    
    
      
        
      
        
      
    
    
      
      
    
    
      
        
        
      
    
    <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
      
        
  
  
    
  
  
    <a href="../../../%E9%A1%B9%E7%9B%AE%E8%AE%BE%E8%AE%A1/00.51/%E5%9F%BA%E4%BA%8E51%E5%8D%95%E7%89%87%E6%9C%BA%E7%9A%84%E6%8E%A7%E5%88%B6%E5%9B%9B%E7%BA%BF%E6%AD%A5%E8%BF%9B%E7%94%B5%E6%9C%BA%E4%BB%BF%E7%9C%9F%E8%AE%BE%E8%AE%A1/" class="md-nav__link">
      
  
  <span class="md-ellipsis">
    项目设计
    
  </span>
  

      
        <span class="md-nav__icon md-icon"></span>
      
    </a>
  

  

      
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#_1" class="md-nav__link">
    <span class="md-ellipsis">
      说明
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#makefile" class="md-nav__link">
    <span class="md-ellipsis">
      Makefile基础
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Makefile基础">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#_2" class="md-nav__link">
    <span class="md-ellipsis">
      最终目标
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_3" class="md-nav__link">
    <span class="md-ellipsis">
      伪目标
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_4" class="md-nav__link">
    <span class="md-ellipsis">
      依赖
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_5" class="md-nav__link">
    <span class="md-ellipsis">
      变量
    </span>
  </a>
  
    <nav class="md-nav" aria-label="变量">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#_6" class="md-nav__link">
    <span class="md-ellipsis">
      条件赋值
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_7" class="md-nav__link">
    <span class="md-ellipsis">
      追加赋值
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#shell" class="md-nav__link">
    <span class="md-ellipsis">
      shell运行赋值
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_8" class="md-nav__link">
    <span class="md-ellipsis">
      多行变量
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_9" class="md-nav__link">
    <span class="md-ellipsis">
      清楚变量
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_10" class="md-nav__link">
    <span class="md-ellipsis">
      环境变量的使用
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_11" class="md-nav__link">
    <span class="md-ellipsis">
      变量替换引用
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_12" class="md-nav__link">
    <span class="md-ellipsis">
      变量覆盖
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_13" class="md-nav__link">
    <span class="md-ellipsis">
      自动变量
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_14" class="md-nav__link">
    <span class="md-ellipsis">
      条件判断
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_15" class="md-nav__link">
    <span class="md-ellipsis">
      处理函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="处理函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#_16" class="md-nav__link">
    <span class="md-ellipsis">
      字符替换与分析
    </span>
  </a>
  
    <nav class="md-nav" aria-label="字符替换与分析">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#subst" class="md-nav__link">
    <span class="md-ellipsis">
      subst
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#strip" class="md-nav__link">
    <span class="md-ellipsis">
      strip
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#findstring" class="md-nav__link">
    <span class="md-ellipsis">
      findstring
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#filter" class="md-nav__link">
    <span class="md-ellipsis">
      filter
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#filter-out" class="md-nav__link">
    <span class="md-ellipsis">
      filter-out
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#sort" class="md-nav__link">
    <span class="md-ellipsis">
      sort
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#word" class="md-nav__link">
    <span class="md-ellipsis">
      word
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#wordlist" class="md-nav__link">
    <span class="md-ellipsis">
      wordlist
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#words" class="md-nav__link">
    <span class="md-ellipsis">
      words
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#firstword" class="md-nav__link">
    <span class="md-ellipsis">
      firstword
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#lastword" class="md-nav__link">
    <span class="md-ellipsis">
      lastword
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_17" class="md-nav__link">
    <span class="md-ellipsis">
      文件名处理函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="文件名处理函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#dir" class="md-nav__link">
    <span class="md-ellipsis">
      dir
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#notdir" class="md-nav__link">
    <span class="md-ellipsis">
      notdir
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#suffix" class="md-nav__link">
    <span class="md-ellipsis">
      suffix
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#basename" class="md-nav__link">
    <span class="md-ellipsis">
      basename
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#addsuffix" class="md-nav__link">
    <span class="md-ellipsis">
      addsuffix
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#addprefix" class="md-nav__link">
    <span class="md-ellipsis">
      addprefix
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#join" class="md-nav__link">
    <span class="md-ellipsis">
      join
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#wildcard" class="md-nav__link">
    <span class="md-ellipsis">
      wildcard
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#realpath" class="md-nav__link">
    <span class="md-ellipsis">
      realpath
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#abspath" class="md-nav__link">
    <span class="md-ellipsis">
      abspath
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_18" class="md-nav__link">
    <span class="md-ellipsis">
      条件函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="条件函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#if" class="md-nav__link">
    <span class="md-ellipsis">
      if
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#or" class="md-nav__link">
    <span class="md-ellipsis">
      or
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#and" class="md-nav__link">
    <span class="md-ellipsis">
      and
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#intcmp" class="md-nav__link">
    <span class="md-ellipsis">
      intcmp
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#file" class="md-nav__link">
    <span class="md-ellipsis">
      file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foreach" class="md-nav__link">
    <span class="md-ellipsis">
      foreach
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#call" class="md-nav__link">
    <span class="md-ellipsis">
      call
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#value" class="md-nav__link">
    <span class="md-ellipsis">
      value
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#origin" class="md-nav__link">
    <span class="md-ellipsis">
      origin
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#flavor" class="md-nav__link">
    <span class="md-ellipsis">
      flavor
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#eval" class="md-nav__link">
    <span class="md-ellipsis">
      eval
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#shell_1" class="md-nav__link">
    <span class="md-ellipsis">
      shell
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#let" class="md-nav__link">
    <span class="md-ellipsis">
      let
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#_19" class="md-nav__link">
    <span class="md-ellipsis">
      信息提示函数
    </span>
  </a>
  
    <nav class="md-nav" aria-label="信息提示函数">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#error" class="md-nav__link">
    <span class="md-ellipsis">
      error
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#warning" class="md-nav__link">
    <span class="md-ellipsis">
      warning
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#info" class="md-nav__link">
    <span class="md-ellipsis">
      info
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_20" class="md-nav__link">
    <span class="md-ellipsis">
      
    </span>
  </a>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              <article class="md-content__inner md-typeset">
                
                  



<h2 id="_1">说明<a class="headerlink" href="#_1" title="Permanent link">&para;</a></h2>
<p>这篇笔记将简要介绍Makefile的使用方式并且记录一些常用的makefile相关函数。主要使用还是在树莓派上面实现。</p>
<p>本文主要是看的B站<a href="https://www.bilibili.com/video/BV1Bv4y1J7QT/?spm_id_from=333.337.top_right_bar_window_custom_collection.content.click&amp;vd_source=fcf02d9420f87f9d13e80731eaba983f">从零开始学Makefile做的笔记</a>，这篇文章使用的代码测试也是使用的他视频提供的代码。但是我只实现了Makefile基础部分的内容，后面的内容没有实现。</p>
<p>参考开源链接：<a href="https://gitee.com/unlimited13/cpp">https://gitee.com/unlimited13/cpp</a></p>
<h2 id="makefile">Makefile基础<a class="headerlink" href="#makefile" title="Permanent link">&para;</a></h2>
<p>我们可以先查看一下我们树莓派的make版本，下面是我的打印信息，有版本，许可等。</p>
<div class="language-bash highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="o">(</span>myenv<span class="o">)</span><span class="w"> </span>pi@raspberrypi:~/Example/12_Makefile<span class="w"> </span>$<span class="w"> </span>make<span class="w"> </span>--version
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a>GNU<span class="w"> </span>Make<span class="w"> </span><span class="m">4</span>.3
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a>为<span class="w"> </span>aarch64-unknown-linux-gnu<span class="w"> </span>编译
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a>Copyright<span class="w"> </span><span class="o">(</span>C<span class="o">)</span><span class="w"> </span><span class="m">1988</span>-2020<span class="w"> </span>Free<span class="w"> </span>Software<span class="w"> </span>Foundation,<span class="w"> </span>Inc.
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a>许可证：GPLv3+：GNU<span class="w"> </span>通用公共许可证第<span class="w"> </span><span class="m">3</span><span class="w"> </span>版或更新版本&lt;http://gnu.org/licenses/gpl.html&gt;。
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a>本软件是自由软件：您可以自由修改和重新发布它。
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a>在法律允许的范围内没有其他保证。
</span></code></pre></div>
<p>建立一个Makefile文件，我们先写一个简易的文件，Makefile就是一个编译和链接多个文件的工具，下面这个就是一个简单的例子，hello是目标文件，hello.cpp是依赖，再另起一行的就是怎么使用这个依赖生成目标。</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="nf">hello</span><span class="o">:</span><span class="w"> </span><span class="n">hello</span>.<span class="n">cpp</span>
</span><span id="__span-1-2"><a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a><span class="w">    </span>g++<span class="w"> </span>hello.cpp<span class="w"> </span>-o<span class="w"> </span>hello<span class="w"> </span><span class="c1"># 开头必须为一个Tab，不能为空格</span>
</span></code></pre></div>
<p>写一个复杂一点的，也就是他提供的这个项目的Makefile，在复制的时候注意他的另起一行要用Tab，不能是空格，不然会报错**Makefile:2: 缺失分隔符。 停止。**</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="nf">sudoku</span><span class="o">:</span><span class="w"> </span><span class="n">block</span>.<span class="n">o</span> <span class="n">command</span>.<span class="n">o</span> <span class="n">input</span>.<span class="n">o</span> <span class="n">main</span>.<span class="n">o</span> <span class="n">scene</span>.<span class="n">o</span> <span class="n">test</span>.<span class="n">o</span>
</span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a><span class="w">    </span>g++<span class="w"> </span>-o<span class="w"> </span>sudoku<span class="w"> </span>block.o<span class="w"> </span>command.o<span class="w"> </span>input.o<span class="w"> </span>main.o<span class="w"> </span>scene.o<span class="w"> </span>test.o
</span><span id="__span-2-3"><a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a>
</span><span id="__span-2-4"><a id="__codelineno-2-4" name="__codelineno-2-4" href="#__codelineno-2-4"></a><span class="nf">block.o</span><span class="o">:</span><span class="w"> </span><span class="n">block</span>.<span class="n">cpp</span> <span class="n">common</span>.<span class="n">h</span> <span class="n">block</span>.<span class="n">h</span> <span class="n">color</span>.<span class="n">h</span>
</span><span id="__span-2-5"><a id="__codelineno-2-5" name="__codelineno-2-5" href="#__codelineno-2-5"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>block.cpp
</span><span id="__span-2-6"><a id="__codelineno-2-6" name="__codelineno-2-6" href="#__codelineno-2-6"></a>
</span><span id="__span-2-7"><a id="__codelineno-2-7" name="__codelineno-2-7" href="#__codelineno-2-7"></a><span class="nf">command.o</span><span class="o">:</span><span class="w"> </span><span class="n">command</span>.<span class="n">cpp</span> <span class="n">scene</span>.<span class="n">h</span> <span class="n">common</span>.<span class="n">h</span> <span class="n">block</span>.<span class="n">h</span> <span class="n">command</span>.<span class="n">h</span>
</span><span id="__span-2-8"><a id="__codelineno-2-8" name="__codelineno-2-8" href="#__codelineno-2-8"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>command.cpp
</span><span id="__span-2-9"><a id="__codelineno-2-9" name="__codelineno-2-9" href="#__codelineno-2-9"></a>
</span><span id="__span-2-10"><a id="__codelineno-2-10" name="__codelineno-2-10" href="#__codelineno-2-10"></a><span class="nf">input.o</span><span class="o">:</span><span class="w"> </span><span class="n">input</span>.<span class="n">cpp</span> <span class="n">common</span>.<span class="n">h</span> <span class="n">utility</span>.<span class="n">inl</span>
</span><span id="__span-2-11"><a id="__codelineno-2-11" name="__codelineno-2-11" href="#__codelineno-2-11"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>input.cpp
</span><span id="__span-2-12"><a id="__codelineno-2-12" name="__codelineno-2-12" href="#__codelineno-2-12"></a>
</span><span id="__span-2-13"><a id="__codelineno-2-13" name="__codelineno-2-13" href="#__codelineno-2-13"></a><span class="nf">main.o</span><span class="o">:</span><span class="w"> </span><span class="n">main</span>.<span class="n">cpp</span> <span class="n">scene</span>.<span class="n">h</span> <span class="n">common</span>.<span class="n">h</span> <span class="n">block</span>.<span class="n">h</span> <span class="n">command</span>.<span class="n">h</span> <span class="n">input</span>.<span class="n">h</span>
</span><span id="__span-2-14"><a id="__codelineno-2-14" name="__codelineno-2-14" href="#__codelineno-2-14"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>main.cpp
</span><span id="__span-2-15"><a id="__codelineno-2-15" name="__codelineno-2-15" href="#__codelineno-2-15"></a>
</span><span id="__span-2-16"><a id="__codelineno-2-16" name="__codelineno-2-16" href="#__codelineno-2-16"></a><span class="nf">scene.o</span><span class="o">:</span><span class="w"> </span><span class="n">scene</span>.<span class="n">cpp</span> <span class="n">common</span>.<span class="n">h</span> <span class="n">scene</span>.<span class="n">h</span> <span class="n">block</span>.<span class="n">h</span> <span class="n">command</span>.<span class="n">h</span> <span class="n">utility</span>.<span class="n">inl</span>
</span><span id="__span-2-17"><a id="__codelineno-2-17" name="__codelineno-2-17" href="#__codelineno-2-17"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>scene.cpp
</span><span id="__span-2-18"><a id="__codelineno-2-18" name="__codelineno-2-18" href="#__codelineno-2-18"></a>
</span><span id="__span-2-19"><a id="__codelineno-2-19" name="__codelineno-2-19" href="#__codelineno-2-19"></a><span class="nf">test.o</span><span class="o">:</span><span class="w"> </span><span class="n">test</span>.<span class="n">cpp</span> <span class="n">test</span>.<span class="n">h</span> <span class="n">scene</span>.<span class="n">h</span> <span class="n">common</span>.<span class="n">h</span> <span class="n">block</span>.<span class="n">h</span> <span class="n">command</span>.<span class="n">h</span>
</span><span id="__span-2-20"><a id="__codelineno-2-20" name="__codelineno-2-20" href="#__codelineno-2-20"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>test.cpp
</span><span id="__span-2-21"><a id="__codelineno-2-21" name="__codelineno-2-21" href="#__codelineno-2-21"></a>
</span><span id="__span-2-22"><a id="__codelineno-2-22" name="__codelineno-2-22" href="#__codelineno-2-22"></a><span class="nf">hello.o</span><span class="o">:</span><span class="w"> </span><span class="n">hello</span>.<span class="n">cpp</span>
</span><span id="__span-2-23"><a id="__codelineno-2-23" name="__codelineno-2-23" href="#__codelineno-2-23"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>hello.cpp
</span><span id="__span-2-24"><a id="__codelineno-2-24" name="__codelineno-2-24" href="#__codelineno-2-24"></a>
</span><span id="__span-2-25"><a id="__codelineno-2-25" name="__codelineno-2-25" href="#__codelineno-2-25"></a>
</span><span id="__span-2-26"><a id="__codelineno-2-26" name="__codelineno-2-26" href="#__codelineno-2-26"></a><span class="nf">clean</span><span class="o">:</span>
</span><span id="__span-2-27"><a id="__codelineno-2-27" name="__codelineno-2-27" href="#__codelineno-2-27"></a><span class="w">    </span>rm<span class="w"> </span>block.o<span class="w"> </span>command.o<span class="w"> </span>input.o<span class="w"> </span>main.o<span class="w"> </span>scene.o<span class="w"> </span>test.o
</span><span id="__span-2-28"><a id="__codelineno-2-28" name="__codelineno-2-28" href="#__codelineno-2-28"></a><span class="w">    </span>rm<span class="w"> </span>sudoku
</span></code></pre></div>
<h3 id="_2">最终目标<a class="headerlink" href="#_2" title="Permanent link">&para;</a></h3>
<ol>
<li>
<p>Makefile中会有很多目标，但最终目标只有一个，其他所有内容都是为这个最终目标服务的，写Makefile的时候**先写出最终目标，再依次解决总目标的依赖**</p>
</li>
<li>
<p>一般情况第一条规则中的目标会被确立为最终目标，第一条规则默认会被make执行。</p>
</li>
<li>
<p>通常来说目标是一个文件，一条规则的目的就是生成或更新目标文件。</p>
</li>
<li>
<p>make会根据目标文件和依赖文件最后修改时间判断是否需要执行更新目标文件的方法。如果目标文件不存在或者目标文件最后修改时间早于其中一个依赖文件最后修改时间，则重新执行更新目标文件的方法。否则不会执行。</p>
</li>
<li>
<p>除了最终目标对应的更新方法默认会执行外，如果Makefile中一个目标不是其他目标的依赖，那么这个目标对应的规则不会自动执行。需要手动指定，方法为</p>
</li>
</ol>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="err">make</span><span class="w"> </span><span class="err">&lt;target&gt;</span><span class="w">  </span><span class="c"># 如 make clean , make hello.o</span>
</span></code></pre></div>
<ol>
<li>可以使用.DEFAULT_GOAL来修改默认最终目标</li>
</ol>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a><span class="nv">.DEFAULT_GOAL</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>main
</span><span id="__span-4-2"><a id="__codelineno-4-2" name="__codelineno-4-2" href="#__codelineno-4-2"></a>
</span><span id="__span-4-3"><a id="__codelineno-4-3" name="__codelineno-4-3" href="#__codelineno-4-3"></a><span class="nf">all</span><span class="o">:</span><span class="w"> </span>
</span><span id="__span-4-4"><a id="__codelineno-4-4" name="__codelineno-4-4" href="#__codelineno-4-4"></a><span class="w">    </span>@echo<span class="w"> </span>all
</span><span id="__span-4-5"><a id="__codelineno-4-5" name="__codelineno-4-5" href="#__codelineno-4-5"></a>
</span><span id="__span-4-6"><a id="__codelineno-4-6" name="__codelineno-4-6" href="#__codelineno-4-6"></a><span class="nf">main</span><span class="o">:</span>
</span><span id="__span-4-7"><a id="__codelineno-4-7" name="__codelineno-4-7" href="#__codelineno-4-7"></a><span class="w">    </span>@echo<span class="w"> </span>main
</span></code></pre></div>
<h3 id="_3">伪目标<a class="headerlink" href="#_3" title="Permanent link">&para;</a></h3>
<p>如果我们文件目录下有一个文件和我们的执行目标重名，就会冲突，比如我们的Makefile文件中有clean，如果文件夹中还有clean就会冲突。这时候我们一般会给这个目标加一个标识<code>.PHONY</code>，设置为伪目标，就不会冲突了。</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-5-1"><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a><span class="nf">.PHONY</span><span class="o">:</span><span class="w"> </span><span class="n">clean</span>
</span><span id="__span-5-2"><a id="__codelineno-5-2" name="__codelineno-5-2" href="#__codelineno-5-2"></a><span class="nf">clean</span><span class="o">:</span>
</span><span id="__span-5-3"><a id="__codelineno-5-3" name="__codelineno-5-3" href="#__codelineno-5-3"></a><span class="w">    </span>rm<span class="w"> </span>block.o<span class="w"> </span>command.o<span class="w"> </span>input.o<span class="w"> </span>main.o<span class="w"> </span>scene.o<span class="w"> </span>test.o
</span><span id="__span-5-4"><a id="__codelineno-5-4" name="__codelineno-5-4" href="#__codelineno-5-4"></a><span class="w">    </span>rm<span class="w"> </span>sudoku.exe
</span></code></pre></div>
<h3 id="_4">依赖<a class="headerlink" href="#_4" title="Permanent link">&para;</a></h3>
<p>依赖分为两种，一种是普通依赖，就是我们上面介绍的那种，一种是**order-only依赖**，但依赖文件更新并不会导致目标文件的更新。比如下面的用|分割的<code>test.o</code>就是这种依赖，他的更新不会引起sudoku的更新。</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-6-1"><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><span class="nf">sudoku</span><span class="o">:</span><span class="w"> </span><span class="n">block</span>.<span class="n">o</span> <span class="n">command</span>.<span class="n">o</span> <span class="n">input</span>.<span class="n">o</span> <span class="n">main</span>.<span class="n">o</span> <span class="n">scene</span>.<span class="n">o</span> <span class="p">|</span> <span class="n">test</span>.<span class="n">o</span>
</span></code></pre></div>
<h3 id="_5">变量<a class="headerlink" href="#_5" title="Permanent link">&para;</a></h3>
<p>变量可以用来就是代替重复出现的内容。</p>
<p>如上面的makefile文件</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-7-1"><a id="__codelineno-7-1" name="__codelineno-7-1" href="#__codelineno-7-1"></a><span class="nv">objects</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>block.o<span class="w"> </span>command.o<span class="w"> </span>input.o<span class="w"> </span>main.o<span class="w"> </span>scene.o<span class="w"> </span>test.o
</span><span id="__span-7-2"><a id="__codelineno-7-2" name="__codelineno-7-2" href="#__codelineno-7-2"></a><span class="nf">sudoku</span><span class="o">:</span><span class="w"> </span><span class="k">$(</span><span class="nv">objects</span><span class="k">)</span>
</span><span id="__span-7-3"><a id="__codelineno-7-3" name="__codelineno-7-3" href="#__codelineno-7-3"></a><span class="w">    </span>g++<span class="w"> </span>-o<span class="w"> </span>sudoku<span class="w"> </span><span class="k">$(</span>objects<span class="k">)</span>
</span><span id="__span-7-4"><a id="__codelineno-7-4" name="__codelineno-7-4" href="#__codelineno-7-4"></a>
</span><span id="__span-7-5"><a id="__codelineno-7-5" name="__codelineno-7-5" href="#__codelineno-7-5"></a><span class="c">#省略中间......</span>
</span><span id="__span-7-6"><a id="__codelineno-7-6" name="__codelineno-7-6" href="#__codelineno-7-6"></a>
</span><span id="__span-7-7"><a id="__codelineno-7-7" name="__codelineno-7-7" href="#__codelineno-7-7"></a><span class="nf">clean</span><span class="o">:</span>
</span><span id="__span-7-8"><a id="__codelineno-7-8" name="__codelineno-7-8" href="#__codelineno-7-8"></a><span class="w">    </span>rm<span class="w"> </span><span class="k">$(</span>objects<span class="k">)</span>
</span><span id="__span-7-9"><a id="__codelineno-7-9" name="__codelineno-7-9" href="#__codelineno-7-9"></a><span class="w">    </span>rm<span class="w"> </span>sudoku
</span></code></pre></div>
<p>变量，只有字符串，有几种常用变量的方式，<code>=</code>是延迟展开，既Makefile文件已经构建好了，想要使用的时候才展开。<code>:=</code>是立即展开，就类似一行行执行。</p>
<div class="language-c highlight"><pre><span></span><code><span id="__span-8-1"><a id="__codelineno-8-1" name="__codelineno-8-1" href="#__codelineno-8-1"></a><span class="n">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">main</span><span class="p">.</span><span class="n">cpp</span><span class="w"> </span><span class="n">hello</span><span class="p">.</span><span class="n">cpp</span>
</span><span id="__span-8-2"><a id="__codelineno-8-2" name="__codelineno-8-2" href="#__codelineno-8-2"></a><span class="nl">objects</span><span class="w"> </span><span class="p">:</span><span class="o">=</span><span class="w"> </span><span class="n">main</span><span class="p">.</span><span class="n">o</span><span class="w"> </span><span class="n">hello</span><span class="p">.</span><span class="n">o</span>
</span></code></pre></div>
<p>变量还有几种常用的方法</p>
<h4 id="_6">条件赋值<a class="headerlink" href="#_6" title="Permanent link">&para;</a></h4>
<p>他会检查前面是否有定义，有定义就不执行</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-9-1"><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a><span class="nv">var1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">100</span>
</span><span id="__span-9-2"><a id="__codelineno-9-2" name="__codelineno-9-2" href="#__codelineno-9-2"></a><span class="nv">var1</span><span class="w"> </span><span class="o">?=</span><span class="w"> </span><span class="m">200</span>
</span></code></pre></div>
<h4 id="_7">追加赋值<a class="headerlink" href="#_7" title="Permanent link">&para;</a></h4>
<p>他会在原变量后面添加新的值</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-10-1"><a id="__codelineno-10-1" name="__codelineno-10-1" href="#__codelineno-10-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>main.cpp
</span><span id="__span-10-2"><a id="__codelineno-10-2" name="__codelineno-10-2" href="#__codelineno-10-2"></a><span class="nv">files</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span>hello.cpp
</span></code></pre></div>
<h4 id="shell">shell运行赋值<a class="headerlink" href="#shell" title="Permanent link">&para;</a></h4>
<p>他会把shell指令执行的结果赋值给变量</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-11-1"><a id="__codelineno-11-1" name="__codelineno-11-1" href="#__codelineno-11-1"></a><span class="nv">gcc_version</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span>gcc<span class="w"> </span>--version
</span><span id="__span-11-2"><a id="__codelineno-11-2" name="__codelineno-11-2" href="#__codelineno-11-2"></a><span class="nv">files</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span>ls<span class="w"> </span>.
</span></code></pre></div>
<h4 id="_8">多行变量<a class="headerlink" href="#_8" title="Permanent link">&para;</a></h4>
<p>常见的变量都是单行的，多行变量常用于定义shell指令</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-12-1"><a id="__codelineno-12-1" name="__codelineno-12-1" href="#__codelineno-12-1"></a><span class="cp">define &lt;varable_name&gt;  # 默认为 = </span>
</span><span id="__span-12-2"><a id="__codelineno-12-2" name="__codelineno-12-2" href="#__codelineno-12-2"></a><span class="c"># 变量内容</span>
</span><span id="__span-12-3"><a id="__codelineno-12-3" name="__codelineno-12-3" href="#__codelineno-12-3"></a><span class="cp">endef</span>
</span><span id="__span-12-4"><a id="__codelineno-12-4" name="__codelineno-12-4" href="#__codelineno-12-4"></a>
</span><span id="__span-12-5"><a id="__codelineno-12-5" name="__codelineno-12-5" href="#__codelineno-12-5"></a><span class="cp">define &lt;varable_name&gt; :=</span>
</span><span id="__span-12-6"><a id="__codelineno-12-6" name="__codelineno-12-6" href="#__codelineno-12-6"></a><span class="c"># 变量内容</span>
</span><span id="__span-12-7"><a id="__codelineno-12-7" name="__codelineno-12-7" href="#__codelineno-12-7"></a><span class="cp">endef</span>
</span><span id="__span-12-8"><a id="__codelineno-12-8" name="__codelineno-12-8" href="#__codelineno-12-8"></a>
</span><span id="__span-12-9"><a id="__codelineno-12-9" name="__codelineno-12-9" href="#__codelineno-12-9"></a><span class="cp">define &lt;varable_name&gt; +=</span>
</span><span id="__span-12-10"><a id="__codelineno-12-10" name="__codelineno-12-10" href="#__codelineno-12-10"></a><span class="c"># 变量内容</span>
</span><span id="__span-12-11"><a id="__codelineno-12-11" name="__codelineno-12-11" href="#__codelineno-12-11"></a><span class="cp">endef</span>
</span></code></pre></div>
<h4 id="_9">清楚变量<a class="headerlink" href="#_9" title="Permanent link">&para;</a></h4>
<p>如果想清除一个变量，用以下方法</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-13-1"><a id="__codelineno-13-1" name="__codelineno-13-1" href="#__codelineno-13-1"></a><span class="err">undefine</span><span class="w"> </span><span class="err">&lt;变量名&gt;</span><span class="w">   </span><span class="err">如</span><span class="w"> </span><span class="err">undefine</span><span class="w"> </span><span class="err">files,</span><span class="w">  </span><span class="err">undefine</span><span class="w"> </span><span class="err">objs</span>
</span></code></pre></div>
<h4 id="_10">环境变量的使用<a class="headerlink" href="#_10" title="Permanent link">&para;</a></h4>
<p>系统中的环境变量可以直接在Makefile中直接使用，使用方法跟普通变量一样</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-14-1"><a id="__codelineno-14-1" name="__codelineno-14-1" href="#__codelineno-14-1"></a><span class="nf">all</span><span class="o">:</span>
</span><span id="__span-14-2"><a id="__codelineno-14-2" name="__codelineno-14-2" href="#__codelineno-14-2"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>USERNAME<span class="k">)</span>
</span><span id="__span-14-3"><a id="__codelineno-14-3" name="__codelineno-14-3" href="#__codelineno-14-3"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>JAVA_HOME<span class="k">)</span>
</span><span id="__span-14-4"><a id="__codelineno-14-4" name="__codelineno-14-4" href="#__codelineno-14-4"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>SystemRoot<span class="k">)</span>
</span></code></pre></div>
<h4 id="_11">变量替换引用<a class="headerlink" href="#_11" title="Permanent link">&para;</a></h4>
<p>语法：<strong>$(var:a=b)</strong>，意思是将变量var的值当中每一项结尾的a替换为b，直接上例子</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-15-1"><a id="__codelineno-15-1" name="__codelineno-15-1" href="#__codelineno-15-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>main.cpp<span class="w"> </span>hello.cpp
</span><span id="__span-15-2"><a id="__codelineno-15-2" name="__codelineno-15-2" href="#__codelineno-15-2"></a><span class="nv">objs</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="k">$(</span>files:.cpp<span class="o">=</span>.o<span class="k">)</span><span class="w"> </span><span class="c1"># main.o hello.o</span>
</span><span id="__span-15-3"><a id="__codelineno-15-3" name="__codelineno-15-3" href="#__codelineno-15-3"></a><span class="c"># 另一种写法</span>
</span><span id="__span-15-4"><a id="__codelineno-15-4" name="__codelineno-15-4" href="#__codelineno-15-4"></a><span class="nv">objs</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="k">$(</span>files:%.cpp<span class="o">=</span>%.o<span class="k">)</span>
</span></code></pre></div>
<h4 id="_12">变量覆盖<a class="headerlink" href="#_12" title="Permanent link">&para;</a></h4>
<p>所有在Makefile中的变量，都可以在执行make时能过指定参数的方式进行覆盖。</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-16-1"><a id="__codelineno-16-1" name="__codelineno-16-1" href="#__codelineno-16-1"></a><span class="nv">OverridDemo</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span>ThisIsInMakefile
</span><span id="__span-16-2"><a id="__codelineno-16-2" name="__codelineno-16-2" href="#__codelineno-16-2"></a><span class="nf">all</span><span class="o">:</span>
</span><span id="__span-16-3"><a id="__codelineno-16-3" name="__codelineno-16-3" href="#__codelineno-16-3"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>OverridDemo<span class="k">)</span>
</span></code></pre></div>
<p>如果直接执行</p>
<div class="language-shell highlight"><pre><span></span><code><span id="__span-17-1"><a id="__codelineno-17-1" name="__codelineno-17-1" href="#__codelineno-17-1"></a>make
</span></code></pre></div>
<p>则上面的输出内容为*ThisIsInMakefile*，但可以在执行make时指定参数：</p>
<div class="language-shell highlight"><pre><span></span><code><span id="__span-18-1"><a id="__codelineno-18-1" name="__codelineno-18-1" href="#__codelineno-18-1"></a>make<span class="w"> </span><span class="nv">OverridDemo</span><span class="o">=</span>ThisIsFromOutShell<span class="w"> </span><span class="c1"># 等号两边不能有空格</span>
</span><span id="__span-18-2"><a id="__codelineno-18-2" name="__codelineno-18-2" href="#__codelineno-18-2"></a><span class="c1"># 如果变量值中有空格，需要用引号</span>
</span><span id="__span-18-3"><a id="__codelineno-18-3" name="__codelineno-18-3" href="#__codelineno-18-3"></a>make<span class="w"> </span><span class="nv">OverridDemo</span><span class="o">=</span>“This<span class="w"> </span>Is<span class="w"> </span>From<span class="w"> </span>Out<span class="w"> </span>Shell”
</span></code></pre></div>
<p>则输出OverridDemo的值是ThisIsFromOutShell或This Is From Out Shell。</p>
<p>用这样的命令参数会覆盖Makefile中对应变量的值，如果不想被覆盖，可以在变量前加上override指令，override具有较高优先级，不会被命令参数覆盖</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-19-1"><a id="__codelineno-19-1" name="__codelineno-19-1" href="#__codelineno-19-1"></a><span class="nf">override OverridDemo </span><span class="o">:</span>= <span class="n">ThisIsInMakefile</span>
</span><span id="__span-19-2"><a id="__codelineno-19-2" name="__codelineno-19-2" href="#__codelineno-19-2"></a><span class="nf">all</span><span class="o">:</span>
</span><span id="__span-19-3"><a id="__codelineno-19-3" name="__codelineno-19-3" href="#__codelineno-19-3"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>OverridDemo<span class="k">)</span>
</span></code></pre></div>
<p>这样即使命令行指定参数</p>
<div class="language-shell highlight"><pre><span></span><code><span id="__span-20-1"><a id="__codelineno-20-1" name="__codelineno-20-1" href="#__codelineno-20-1"></a>make<span class="w"> </span><span class="nv">OverridDemo</span><span class="o">=</span>ThisIsFromOutShell
</span></code></pre></div>
<p>输出结果依然是ThisIsInMakefile</p>
<h3 id="_13">自动变量<a class="headerlink" href="#_13" title="Permanent link">&para;</a></h3>
<p>上面的Makefile文件，看着还是很长，makefile中有许多自动变量可以批量替换文件</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-21-1"><a id="__codelineno-21-1" name="__codelineno-21-1" href="#__codelineno-21-1"></a><span class="k">$@</span><span class="err">：①本条规则的目标名；②如果目标是归档文件的成员，则为归档文件名；③在多目标的模式规则中,</span><span class="w"> </span><span class="err">为导致本条规则方法执行的那个目标名；</span>
</span><span id="__span-21-2"><a id="__codelineno-21-2" name="__codelineno-21-2" href="#__codelineno-21-2"></a><span class="k">$&lt;</span><span class="err">：本条规则的第一个依赖名称</span>
</span><span id="__span-21-3"><a id="__codelineno-21-3" name="__codelineno-21-3" href="#__codelineno-21-3"></a><span class="k">$?</span><span class="err">：依赖中修改时间晚于目标文件修改时间的所有文件名，以空格隔开</span>
</span><span id="__span-21-4"><a id="__codelineno-21-4" name="__codelineno-21-4" href="#__codelineno-21-4"></a><span class="err">$^：所有依赖文件名，文件名不会重复，不包含order-only依赖</span>
</span><span id="__span-21-5"><a id="__codelineno-21-5" name="__codelineno-21-5" href="#__codelineno-21-5"></a><span class="k">$+</span><span class="err">：类似上一个，</span><span class="w"> </span><span class="err">表示所有依赖文件名，包括重复的文件名，不包含order-only依赖</span>
</span><span id="__span-21-6"><a id="__codelineno-21-6" name="__codelineno-21-6" href="#__codelineno-21-6"></a><span class="k">$|</span><span class="err">：所有order-only依赖文件名</span>
</span><span id="__span-21-7"><a id="__codelineno-21-7" name="__codelineno-21-7" href="#__codelineno-21-7"></a><span class="k">$*</span><span class="err">：(简单理解)目标文件名的主干部分(即不包括后缀名)</span>
</span><span id="__span-21-8"><a id="__codelineno-21-8" name="__codelineno-21-8" href="#__codelineno-21-8"></a><span class="k">$%</span><span class="err">：如果目标不是归档文件，则为空；如果目标是归档文件成员，则为对应的成员文件名</span>
</span></code></pre></div>
<p>以下变量对应上述变量，D为对应变量所在的目录，结尾不带/，F为对应变量除去目录部分的文件名</p>
<p><strong>$(<a class="magiclink magiclink-github magiclink-mention" href="https://github.com/D" title="GitHub User: D">@D</a>)</strong>  、<strong>$(<a class="magiclink magiclink-github magiclink-mention" href="https://github.com/F" title="GitHub User: F">@F</a>)</strong>、<strong>$(*D)</strong>、<strong>$(*F)</strong>、<strong>$(%D)</strong>、<strong>$(%F)</strong>、<strong>$(&lt;D)</strong>、<strong>$(&lt;F)</strong>、<strong>$(<sup>D)<strong>、</strong>$(</sup>F)</strong>、<strong>$(+D)</strong>、<strong>$(+F)</strong>、<strong>$(?D)</strong>、<strong>$(?F)</strong></p>
<p>按照这个自动变量的解释，我们把上面的makefile进行改进</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-22-1"><a id="__codelineno-22-1" name="__codelineno-22-1" href="#__codelineno-22-1"></a><span class="nf">sudoku</span><span class="o">:</span><span class="w"> </span><span class="k">$(</span><span class="nv">objects</span><span class="k">)</span>
</span><span id="__span-22-2"><a id="__codelineno-22-2" name="__codelineno-22-2" href="#__codelineno-22-2"></a><span class="w">    </span>g++<span class="w"> </span>-o<span class="w"> </span><span class="nv">$@</span><span class="w"> </span><span class="k">$(</span>objects<span class="k">)</span>
</span><span id="__span-22-3"><a id="__codelineno-22-3" name="__codelineno-22-3" href="#__codelineno-22-3"></a>
</span><span id="__span-22-4"><a id="__codelineno-22-4" name="__codelineno-22-4" href="#__codelineno-22-4"></a><span class="nf">%.o</span><span class="o">:</span><span class="w"> </span>%.<span class="n">cpp</span>  
</span><span id="__span-22-5"><a id="__codelineno-22-5" name="__codelineno-22-5" href="#__codelineno-22-5"></a><span class="w">    </span>g++<span class="w"> </span>-c<span class="w"> </span>$&lt;
</span><span id="__span-22-6"><a id="__codelineno-22-6" name="__codelineno-22-6" href="#__codelineno-22-6"></a>
</span><span id="__span-22-7"><a id="__codelineno-22-7" name="__codelineno-22-7" href="#__codelineno-22-7"></a><span class="nf">clean</span><span class="o">:</span>
</span><span id="__span-22-8"><a id="__codelineno-22-8" name="__codelineno-22-8" href="#__codelineno-22-8"></a><span class="w">    </span>rm<span class="w"> </span><span class="k">$(</span>objects<span class="k">)</span>
</span><span id="__span-22-9"><a id="__codelineno-22-9" name="__codelineno-22-9" href="#__codelineno-22-9"></a><span class="w">    </span>rm<span class="w"> </span>sudoku<span class="w"> </span>
</span></code></pre></div>
<p>其实这个就是一个简易的比较完整的Makefile了我感觉。</p>
<h2 id="_14">条件判断<a class="headerlink" href="#_14" title="Permanent link">&para;</a></h2>
<p>使用条件指令可以让make执行或略过Makefile文件中的一些部分。</p>
<p><strong>ifdef</strong>  判断一个变量是已否定义</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-23-1"><a id="__codelineno-23-1" name="__codelineno-23-1" href="#__codelineno-23-1"></a><span class="cp">ifdef Win</span>
</span><span id="__span-23-2"><a id="__codelineno-23-2" name="__codelineno-23-2" href="#__codelineno-23-2"></a><span class="w">    </span><span class="nv">OS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>Windows
</span><span id="__span-23-3"><a id="__codelineno-23-3" name="__codelineno-23-3" href="#__codelineno-23-3"></a><span class="cp">else ifdef Mac</span>
</span><span id="__span-23-4"><a id="__codelineno-23-4" name="__codelineno-23-4" href="#__codelineno-23-4"></a><span class="w">    </span><span class="nv">OS</span><span class="o">=</span><span class="w"> </span>MacOS
</span><span id="__span-23-5"><a id="__codelineno-23-5" name="__codelineno-23-5" href="#__codelineno-23-5"></a><span class="cp">else </span>
</span><span id="__span-23-6"><a id="__codelineno-23-6" name="__codelineno-23-6" href="#__codelineno-23-6"></a><span class="w">    </span><span class="nv">OS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>Linux
</span><span id="__span-23-7"><a id="__codelineno-23-7" name="__codelineno-23-7" href="#__codelineno-23-7"></a><span class="cp">endif</span>
</span></code></pre></div>
<p><strong>ifndef</strong> 判断一个变量是否没被定义</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-24-1"><a id="__codelineno-24-1" name="__codelineno-24-1" href="#__codelineno-24-1"></a><span class="cp">ifndef FLAGS</span>
</span><span id="__span-24-2"><a id="__codelineno-24-2" name="__codelineno-24-2" href="#__codelineno-24-2"></a><span class="w">    </span><span class="nv">FLAGS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>-finput-charset<span class="o">=</span>utf-8
</span><span id="__span-24-3"><a id="__codelineno-24-3" name="__codelineno-24-3" href="#__codelineno-24-3"></a><span class="cp">endif</span>
</span></code></pre></div>
<p><strong>ifeq</strong> 判断两个值是否相等</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-25-1"><a id="__codelineno-25-1" name="__codelineno-25-1" href="#__codelineno-25-1"></a><span class="nv">version</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">3</span>.0
</span><span id="__span-25-2"><a id="__codelineno-25-2" name="__codelineno-25-2" href="#__codelineno-25-2"></a>
</span><span id="__span-25-3"><a id="__codelineno-25-3" name="__codelineno-25-3" href="#__codelineno-25-3"></a><span class="cp">ifeq ($(version),1.0)            # ifeq后一定要一个空格</span>
</span><span id="__span-25-4"><a id="__codelineno-25-4" name="__codelineno-25-4" href="#__codelineno-25-4"></a><span class="w">    </span>msg<span class="w"> </span>:<span class="o">=</span><span class="w"> </span>版本太旧了，请更新版本
</span><span id="__span-25-5"><a id="__codelineno-25-5" name="__codelineno-25-5" href="#__codelineno-25-5"></a><span class="cp">else ifeq ($(version), 3.0)</span>
</span><span id="__span-25-6"><a id="__codelineno-25-6" name="__codelineno-25-6" href="#__codelineno-25-6"></a><span class="w">    </span>msg<span class="w"> </span>:<span class="o">=</span><span class="w"> </span>版本太新了，也不行
</span><span id="__span-25-7"><a id="__codelineno-25-7" name="__codelineno-25-7" href="#__codelineno-25-7"></a><span class="cp">else</span>
</span><span id="__span-25-8"><a id="__codelineno-25-8" name="__codelineno-25-8" href="#__codelineno-25-8"></a><span class="w">    </span>msg<span class="w"> </span>:<span class="o">=</span><span class="w"> </span>版本可以用
</span><span id="__span-25-9"><a id="__codelineno-25-9" name="__codelineno-25-9" href="#__codelineno-25-9"></a><span class="cp">endif</span>
</span><span id="__span-25-10"><a id="__codelineno-25-10" name="__codelineno-25-10" href="#__codelineno-25-10"></a>
</span><span id="__span-25-11"><a id="__codelineno-25-11" name="__codelineno-25-11" href="#__codelineno-25-11"></a><span class="c"># 另外的写法</span>
</span><span id="__span-25-12"><a id="__codelineno-25-12" name="__codelineno-25-12" href="#__codelineno-25-12"></a><span class="nv">msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>Other
</span><span id="__span-25-13"><a id="__codelineno-25-13" name="__codelineno-25-13" href="#__codelineno-25-13"></a><span class="cp">ifeq &quot;$(OS)&quot; &quot;Windows_NT&quot;</span>
</span><span id="__span-25-14"><a id="__codelineno-25-14" name="__codelineno-25-14" href="#__codelineno-25-14"></a><span class="w">    </span><span class="nv">msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>This<span class="w"> </span>is<span class="w"> </span>a<span class="w"> </span>Windows<span class="w"> </span>Platform
</span><span id="__span-25-15"><a id="__codelineno-25-15" name="__codelineno-25-15" href="#__codelineno-25-15"></a><span class="cp">endif</span>
</span></code></pre></div>
<p><strong>ifneq</strong> 判断两个值是否不等</p>
<p>用法及参数同ifeq，只是判断结果相反</p>
<h2 id="_15">处理函数<a class="headerlink" href="#_15" title="Permanent link">&para;</a></h2>
<p>从这里开始，我感觉就和上面的文件没有太大关系了，很多都是一些函数的用法。</p>
<h3 id="_16">字符替换与分析<a class="headerlink" href="#_16" title="Permanent link">&para;</a></h3>
<h4 id="subst"><strong>subst</strong><a class="headerlink" href="#subst" title="Permanent link">&para;</a></h4>
<p>文本替换函数，返回替换后的文本，下面这个例子，就会将objs中的.o替换成.cpp，他是不管后缀的，是直接文本替换。</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-26-1"><a id="__codelineno-26-1" name="__codelineno-26-1" href="#__codelineno-26-1"></a><span class="nv">objs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>main.o<span class="w"> </span>hello.o
</span><span id="__span-26-2"><a id="__codelineno-26-2" name="__codelineno-26-2" href="#__codelineno-26-2"></a><span class="nv">srcs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>subst<span class="w"> </span>.o,.cpp,<span class="k">$(</span>objs<span class="k">))</span>
</span></code></pre></div>
<p><strong>patsubst</strong></p>
<p>模式替换， 返回替换后的文本，这个会把.o结尾的，替换成.cpp，比如这里第一个.o和hello中间没有空格，他就不会被替换。</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-27-1"><a id="__codelineno-27-1" name="__codelineno-27-1" href="#__codelineno-27-1"></a><span class="nv">objs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>main.ohello.o
</span><span id="__span-27-2"><a id="__codelineno-27-2" name="__codelineno-27-2" href="#__codelineno-27-2"></a><span class="nv">srcs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>subst<span class="w"> </span>%.o,%.cpp,<span class="k">$(</span>objs<span class="k">))</span><span class="w"> </span>
</span></code></pre></div>
<h4 id="strip"><strong>strip</strong><a class="headerlink" href="#strip" title="Permanent link">&para;</a></h4>
<p>去除字符串头部和尾部的空格，中间如果连续有多个空格，则用一个空格替换，返回去除空格后的文本</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-28-1"><a id="__codelineno-28-1" name="__codelineno-28-1" href="#__codelineno-28-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>aa<span class="w"> </span>hello.cpp<span class="w">      </span>main.cpp<span class="w">     </span>test.cpp
</span><span id="__span-28-2"><a id="__codelineno-28-2" name="__codelineno-28-2" href="#__codelineno-28-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>strip<span class="w"> </span><span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="findstring">findstring<a class="headerlink" href="#findstring" title="Permanent link">&para;</a></h4>
<p>查找字符串，如果找到了，则返回对应的字符串，如果没找到，则反回空串</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-29-1"><a id="__codelineno-29-1" name="__codelineno-29-1" href="#__codelineno-29-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>test.cpp
</span><span id="__span-29-2"><a id="__codelineno-29-2" name="__codelineno-29-2" href="#__codelineno-29-2"></a><span class="nv">find</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>findstring<span class="w"> </span>hel,<span class="k">$(</span>files<span class="k">))</span>
</span><span id="__span-29-3"><a id="__codelineno-29-3" name="__codelineno-29-3" href="#__codelineno-29-3"></a><span class="nv">find</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>findstring<span class="w"> </span>HEL,<span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="filter">filter<a class="headerlink" href="#filter" title="Permanent link">&para;</a></h4>
<p>从文本中筛选出符合模式的内容并返回</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-30-1"><a id="__codelineno-30-1" name="__codelineno-30-1" href="#__codelineno-30-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>test.cpp<span class="w"> </span>main.o<span class="w"> </span>hello.o<span class="w"> </span>hello.h
</span><span id="__span-30-2"><a id="__codelineno-30-2" name="__codelineno-30-2" href="#__codelineno-30-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>filter<span class="w"> </span>%.o<span class="w"> </span>%.h,<span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="filter-out">filter-out<a class="headerlink" href="#filter-out" title="Permanent link">&para;</a></h4>
<p>与filter相反，过滤掉符合模式的，返回剩下的内容</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-31-1"><a id="__codelineno-31-1" name="__codelineno-31-1" href="#__codelineno-31-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>test.cpp<span class="w"> </span>main.o<span class="w"> </span>hello.o<span class="w"> </span>hello.h
</span><span id="__span-31-2"><a id="__codelineno-31-2" name="__codelineno-31-2" href="#__codelineno-31-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>filter-out<span class="w"> </span>%.o<span class="w"> </span>%.cpp,<span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="sort">sort<a class="headerlink" href="#sort" title="Permanent link">&para;</a></h4>
<p>将文本内的各项按字典顺序排列，并且移除重复项</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-32-1"><a id="__codelineno-32-1" name="__codelineno-32-1" href="#__codelineno-32-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>test.cpp<span class="w"> </span>main.o<span class="w"> </span>hello.o<span class="w"> </span>hello.h<span class="w"> </span>main.cpp<span class="w"> </span>hello.cpp
</span><span id="__span-32-2"><a id="__codelineno-32-2" name="__codelineno-32-2" href="#__codelineno-32-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>sort<span class="w"> </span><span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="word">word<a class="headerlink" href="#word" title="Permanent link">&para;</a></h4>
<p>用于返回文本中第n个单词</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-33-1"><a id="__codelineno-33-1" name="__codelineno-33-1" href="#__codelineno-33-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>test.cpp<span class="w"> </span>main.o<span class="w"> </span>hello.o<span class="w"> </span>hello.h<span class="w"> </span>main.cpp<span class="w"> </span>hello.cpp
</span><span id="__span-33-2"><a id="__codelineno-33-2" name="__codelineno-33-2" href="#__codelineno-33-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>word<span class="w"> </span><span class="m">3</span>,<span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="wordlist">wordlist<a class="headerlink" href="#wordlist" title="Permanent link">&para;</a></h4>
<p>用于返回文本指定范围内的单词列表</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-34-1"><a id="__codelineno-34-1" name="__codelineno-34-1" href="#__codelineno-34-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>test.cpp<span class="w"> </span>main.o<span class="w"> </span>hello.o<span class="w"> </span>hello.h<span class="w"> </span>main.cpp<span class="w"> </span>hello.cpp
</span><span id="__span-34-2"><a id="__codelineno-34-2" name="__codelineno-34-2" href="#__codelineno-34-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>wordlist<span class="w"> </span><span class="m">3</span>,6,<span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="words">words<a class="headerlink" href="#words" title="Permanent link">&para;</a></h4>
<p>返回文本中单词数</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-35-1"><a id="__codelineno-35-1" name="__codelineno-35-1" href="#__codelineno-35-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>test.cpp<span class="w"> </span>main.o<span class="w"> </span>hello.o<span class="w"> </span>hello.h<span class="w"> </span>main.cpp<span class="w"> </span>hello.cpp
</span><span id="__span-35-2"><a id="__codelineno-35-2" name="__codelineno-35-2" href="#__codelineno-35-2"></a><span class="nv">nums</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>words<span class="w"> </span><span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="firstword">firstword<a class="headerlink" href="#firstword" title="Permanent link">&para;</a></h4>
<p>返回第一个单词</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-36-1"><a id="__codelineno-36-1" name="__codelineno-36-1" href="#__codelineno-36-1"></a><span class="k">$(</span><span class="nv">firstword</span> <span class="nv">text</span><span class="k">)</span>
</span></code></pre></div>
<h4 id="lastword">lastword<a class="headerlink" href="#lastword" title="Permanent link">&para;</a></h4>
<p>返回最后一个单词</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-37-1"><a id="__codelineno-37-1" name="__codelineno-37-1" href="#__codelineno-37-1"></a><span class="k">$(</span><span class="nv">lastword</span> <span class="nv">text</span><span class="k">)</span>
</span></code></pre></div>
<h3 id="_17">文件名处理函数<a class="headerlink" href="#_17" title="Permanent link">&para;</a></h3>
<h4 id="dir">dir<a class="headerlink" href="#dir" title="Permanent link">&para;</a></h4>
<p>返回文件目录</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-38-1"><a id="__codelineno-38-1" name="__codelineno-38-1" href="#__codelineno-38-1"></a><span class="k">$(</span><span class="nv">dir</span> <span class="nv">files</span><span class="k">)</span>
</span><span id="__span-38-2"><a id="__codelineno-38-2" name="__codelineno-38-2" href="#__codelineno-38-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">files</span><span class="w"> </span><span class="err">需要返回目录的文件名，可以有多个，用空格隔开</span>
</span><span id="__span-38-3"><a id="__codelineno-38-3" name="__codelineno-38-3" href="#__codelineno-38-3"></a>
</span><span id="__span-38-4"><a id="__codelineno-38-4" name="__codelineno-38-4" href="#__codelineno-38-4"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp
</span><span id="__span-38-5"><a id="__codelineno-38-5" name="__codelineno-38-5" href="#__codelineno-38-5"></a>
</span><span id="__span-38-6"><a id="__codelineno-38-6" name="__codelineno-38-6" href="#__codelineno-38-6"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>dir<span class="w"> </span><span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="notdir">notdir<a class="headerlink" href="#notdir" title="Permanent link">&para;</a></h4>
<p>返回除目录部分的文件名</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-39-1"><a id="__codelineno-39-1" name="__codelineno-39-1" href="#__codelineno-39-1"></a><span class="k">$(</span><span class="nv">notdir</span> <span class="nv">files</span><span class="k">)</span>
</span><span id="__span-39-2"><a id="__codelineno-39-2" name="__codelineno-39-2" href="#__codelineno-39-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">files</span><span class="w"> </span><span class="err">需要返回文件列表，可以有多个，用空格隔开</span>
</span><span id="__span-39-3"><a id="__codelineno-39-3" name="__codelineno-39-3" href="#__codelineno-39-3"></a>
</span><span id="__span-39-4"><a id="__codelineno-39-4" name="__codelineno-39-4" href="#__codelineno-39-4"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp
</span><span id="__span-39-5"><a id="__codelineno-39-5" name="__codelineno-39-5" href="#__codelineno-39-5"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>notdir<span class="w"> </span><span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="suffix">suffix<a class="headerlink" href="#suffix" title="Permanent link">&para;</a></h4>
<p>返回文件后缀名，如果没有后缀返回空</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-40-1"><a id="__codelineno-40-1" name="__codelineno-40-1" href="#__codelineno-40-1"></a><span class="k">$(</span><span class="nv">suffix</span> <span class="nv">files</span><span class="k">)</span>
</span><span id="__span-40-2"><a id="__codelineno-40-2" name="__codelineno-40-2" href="#__codelineno-40-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">files</span><span class="w"> </span><span class="err">需要返回后缀的文件名，可以有多个，用空格隔开</span>
</span><span id="__span-40-3"><a id="__codelineno-40-3" name="__codelineno-40-3" href="#__codelineno-40-3"></a>
</span><span id="__span-40-4"><a id="__codelineno-40-4" name="__codelineno-40-4" href="#__codelineno-40-4"></a>
</span><span id="__span-40-5"><a id="__codelineno-40-5" name="__codelineno-40-5" href="#__codelineno-40-5"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>hello.o<span class="w"> </span>hello.hpp<span class="w"> </span>hello
</span><span id="__span-40-6"><a id="__codelineno-40-6" name="__codelineno-40-6" href="#__codelineno-40-6"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>suffix<span class="w"> </span><span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="basename">basename<a class="headerlink" href="#basename" title="Permanent link">&para;</a></h4>
<p>返回文件名除后缀的部分</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-41-1"><a id="__codelineno-41-1" name="__codelineno-41-1" href="#__codelineno-41-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>hello.o<span class="w"> </span>hello.hpp<span class="w"> </span>hello
</span><span id="__span-41-2"><a id="__codelineno-41-2" name="__codelineno-41-2" href="#__codelineno-41-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>basename<span class="w"> </span><span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="addsuffix">addsuffix<a class="headerlink" href="#addsuffix" title="Permanent link">&para;</a></h4>
<p>给文件名添加后缀</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-42-1"><a id="__codelineno-42-1" name="__codelineno-42-1" href="#__codelineno-42-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>hello.o<span class="w"> </span>hello.hpp<span class="w"> </span>hello
</span><span id="__span-42-2"><a id="__codelineno-42-2" name="__codelineno-42-2" href="#__codelineno-42-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>addsuffix<span class="w"> </span>.exe,<span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="addprefix">addprefix<a class="headerlink" href="#addprefix" title="Permanent link">&para;</a></h4>
<p>给文件名添加前缀</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-43-1"><a id="__codelineno-43-1" name="__codelineno-43-1" href="#__codelineno-43-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>hello.o<span class="w"> </span>hello.hpp<span class="w"> </span>hello
</span><span id="__span-43-2"><a id="__codelineno-43-2" name="__codelineno-43-2" href="#__codelineno-43-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>addprefix<span class="w"> </span>make/,<span class="k">$(</span>files<span class="k">))</span>
</span></code></pre></div>
<h4 id="join">join<a class="headerlink" href="#join" title="Permanent link">&para;</a></h4>
<p>将两个列表中的内容一对一连接，如果两个列表内容数量不相等，则多出来的部分原样返回</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-44-1"><a id="__codelineno-44-1" name="__codelineno-44-1" href="#__codelineno-44-1"></a><span class="nv">f1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello<span class="w"> </span>main<span class="w"> </span><span class="nb">test</span>
</span><span id="__span-44-2"><a id="__codelineno-44-2" name="__codelineno-44-2" href="#__codelineno-44-2"></a><span class="nv">f2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>.cpp<span class="w"> </span>.hpp
</span><span id="__span-44-3"><a id="__codelineno-44-3" name="__codelineno-44-3" href="#__codelineno-44-3"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>join<span class="w"> </span><span class="k">$(</span>f1<span class="k">)</span>,<span class="k">$(</span>f2<span class="k">))</span>
</span></code></pre></div>
<h4 id="wildcard">wildcard<a class="headerlink" href="#wildcard" title="Permanent link">&para;</a></h4>
<p>返回符合通配符的文件列表</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-45-1"><a id="__codelineno-45-1" name="__codelineno-45-1" href="#__codelineno-45-1"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>wildcard<span class="w"> </span>*.cpp<span class="k">)</span>
</span><span id="__span-45-2"><a id="__codelineno-45-2" name="__codelineno-45-2" href="#__codelineno-45-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>wildcard<span class="w"> </span>*<span class="k">)</span>
</span><span id="__span-45-3"><a id="__codelineno-45-3" name="__codelineno-45-3" href="#__codelineno-45-3"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>wildcard<span class="w"> </span>src/*.cpp<span class="k">)</span>
</span></code></pre></div>
<h4 id="realpath">realpath<a class="headerlink" href="#realpath" title="Permanent link">&para;</a></h4>
<p>返回文件的绝对路径</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-46-1"><a id="__codelineno-46-1" name="__codelineno-46-1" href="#__codelineno-46-1"></a><span class="nv">f3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>wildcard<span class="w"> </span>src/*<span class="k">)</span>
</span><span id="__span-46-2"><a id="__codelineno-46-2" name="__codelineno-46-2" href="#__codelineno-46-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>realpath<span class="w"> </span><span class="k">$(</span>f3<span class="k">))</span>
</span></code></pre></div>
<h4 id="abspath">abspath<a class="headerlink" href="#abspath" title="Permanent link">&para;</a></h4>
<p>返回绝对路径，用法同realpath，如果一个文件名不存在，realpath不会返回内容，abspath则会返回一个当前文件夹一下的绝对路径</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-47-1"><a id="__codelineno-47-1" name="__codelineno-47-1" href="#__codelineno-47-1"></a><span class="k">$(</span><span class="nv">abspath</span> <span class="nv">files</span><span class="k">)</span>
</span></code></pre></div>
<h3 id="_18">条件函数<a class="headerlink" href="#_18" title="Permanent link">&para;</a></h3>
<h4 id="if">if<a class="headerlink" href="#if" title="Permanent link">&para;</a></h4>
<p>条件判断，如果条件展开不是空串，则反回真的部分，否则返回假的部分</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-48-1"><a id="__codelineno-48-1" name="__codelineno-48-1" href="#__codelineno-48-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>hello.o<span class="w"> </span>hello.hpp<span class="w"> </span>hello
</span><span id="__span-48-2"><a id="__codelineno-48-2" name="__codelineno-48-2" href="#__codelineno-48-2"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(if</span><span class="w"> </span><span class="k">$(</span>files<span class="k">)</span>,有文件,没有文件<span class="k">)</span>
</span></code></pre></div>
<h4 id="or">or<a class="headerlink" href="#or" title="Permanent link">&para;</a></h4>
<p>返回条件中第一个不为空的部分</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-49-1"><a id="__codelineno-49-1" name="__codelineno-49-1" href="#__codelineno-49-1"></a><span class="nv">f1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>
</span><span id="__span-49-2"><a id="__codelineno-49-2" name="__codelineno-49-2" href="#__codelineno-49-2"></a><span class="nv">f2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>
</span><span id="__span-49-3"><a id="__codelineno-49-3" name="__codelineno-49-3" href="#__codelineno-49-3"></a><span class="nv">f3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp
</span><span id="__span-49-4"><a id="__codelineno-49-4" name="__codelineno-49-4" href="#__codelineno-49-4"></a><span class="nv">f4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>main.cpp
</span><span id="__span-49-5"><a id="__codelineno-49-5" name="__codelineno-49-5" href="#__codelineno-49-5"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>or<span class="w"> </span><span class="k">$(</span>f1<span class="k">)</span>,<span class="k">$(</span>f2<span class="k">)</span>,<span class="k">$(</span>f3<span class="k">)</span>,<span class="k">$(</span>f4<span class="k">))</span>
</span></code></pre></div>
<h4 id="and">and<a class="headerlink" href="#and" title="Permanent link">&para;</a></h4>
<p>如果条件中有一个为空串，则返回空，如果全都不为空，则返回最后一个条件</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-50-1"><a id="__codelineno-50-1" name="__codelineno-50-1" href="#__codelineno-50-1"></a><span class="nv">f1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">12</span>
</span><span id="__span-50-2"><a id="__codelineno-50-2" name="__codelineno-50-2" href="#__codelineno-50-2"></a><span class="nv">f2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">34</span>
</span><span id="__span-50-3"><a id="__codelineno-50-3" name="__codelineno-50-3" href="#__codelineno-50-3"></a><span class="nv">f3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>hello.cpp
</span><span id="__span-50-4"><a id="__codelineno-50-4" name="__codelineno-50-4" href="#__codelineno-50-4"></a><span class="nv">f4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>main.cpp
</span><span id="__span-50-5"><a id="__codelineno-50-5" name="__codelineno-50-5" href="#__codelineno-50-5"></a><span class="nv">files2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>and<span class="w"> </span><span class="k">$(</span>f1<span class="k">)</span>,<span class="k">$(</span>f2<span class="k">)</span>,<span class="k">$(</span>f3<span class="k">)</span>,<span class="k">$(</span>f4<span class="k">))</span>
</span></code></pre></div>
<h4 id="intcmp">intcmp<a class="headerlink" href="#intcmp" title="Permanent link">&para;</a></h4>
<p>比较两个整数大小，并返回对应操作结果（GNU make 4.4以上版本）</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-51-1"><a id="__codelineno-51-1" name="__codelineno-51-1" href="#__codelineno-51-1"></a><span class="k">$(</span><span class="nv">intcmp</span> <span class="nv">lhs</span>,<span class="nv">rhs</span>[,<span class="nv">lt-part</span>[,<span class="nv">eq-part</span>[,<span class="nv">gt-part</span>]]]<span class="k">)</span><span class="w"> </span>
</span><span id="__span-51-2"><a id="__codelineno-51-2" name="__codelineno-51-2" href="#__codelineno-51-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">lhs</span><span class="w"> </span><span class="err">第一个数</span>
</span><span id="__span-51-3"><a id="__codelineno-51-3" name="__codelineno-51-3" href="#__codelineno-51-3"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">rhs</span><span class="w"> </span><span class="err">第二个数</span>
</span><span id="__span-51-4"><a id="__codelineno-51-4" name="__codelineno-51-4" href="#__codelineno-51-4"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">lt-part</span><span class="w">  </span><span class="err">lhs</span><span class="w"> </span><span class="err">&lt;</span><span class="w"> </span><span class="err">rhs时执行</span>
</span><span id="__span-51-5"><a id="__codelineno-51-5" name="__codelineno-51-5" href="#__codelineno-51-5"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">eq-part</span><span class="w">  </span><span class="nv">lhs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>rhs时执行
</span><span id="__span-51-6"><a id="__codelineno-51-6" name="__codelineno-51-6" href="#__codelineno-51-6"></a><span class="w">        </span>---<span class="w"> </span>gt-part<span class="w">  </span>lhs<span class="w"> </span>&gt;<span class="w"> </span>rhs时执行
</span><span id="__span-51-7"><a id="__codelineno-51-7" name="__codelineno-51-7" href="#__codelineno-51-7"></a><span class="w">        </span>---<span class="w"> </span>如果只提供前两个参数，则lhs<span class="w"> </span><span class="o">==</span><span class="w"> </span>rhs时返回数值，否则返回空串
</span><span id="__span-51-8"><a id="__codelineno-51-8" name="__codelineno-51-8" href="#__codelineno-51-8"></a><span class="w">            </span>参数为lhs,rhs,lt-part时，当lhs<span class="w"> </span>&lt;<span class="w"> </span>rhs时返回lt-part结果，否则返回空
</span><span id="__span-51-9"><a id="__codelineno-51-9" name="__codelineno-51-9" href="#__codelineno-51-9"></a><span class="w">            </span>参数为lhs,rhs,lt-part,eq-part，lhs<span class="w"> </span>&lt;<span class="w"> </span>rhs返回lt-part结果，否则都返回eq-part结果
</span><span id="__span-51-10"><a id="__codelineno-51-10" name="__codelineno-51-10" href="#__codelineno-51-10"></a><span class="w">            </span>参数全时，lhs<span class="w"> </span>&lt;<span class="w"> </span>rhs返回lt-part，lhs<span class="w"> </span><span class="o">==</span><span class="w"> </span>rhs返回eq-part,<span class="w"> </span>lhs<span class="w"> </span>&gt;<span class="w"> </span>rhs返回gt-part
</span><span id="__span-51-11"><a id="__codelineno-51-11" name="__codelineno-51-11" href="#__codelineno-51-11"></a>
</span><span id="__span-51-12"><a id="__codelineno-51-12" name="__codelineno-51-12" href="#__codelineno-51-12"></a>
</span><span id="__span-51-13"><a id="__codelineno-51-13" name="__codelineno-51-13" href="#__codelineno-51-13"></a>
</span><span id="__span-51-14"><a id="__codelineno-51-14" name="__codelineno-51-14" href="#__codelineno-51-14"></a><span class="err">@echo</span><span class="w"> </span><span class="k">$(</span><span class="nv">intcmp</span> <span class="nv">2</span>,<span class="nv">2</span>,<span class="nv">-1</span>,<span class="nv">0</span>,<span class="nv">1</span><span class="k">)</span>
</span></code></pre></div>
<h3 id="file">file<a class="headerlink" href="#file" title="Permanent link">&para;</a></h3>
<p>读写文件</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-52-1"><a id="__codelineno-52-1" name="__codelineno-52-1" href="#__codelineno-52-1"></a><span class="k">$(</span><span class="nv">file</span> <span class="nv">op</span> <span class="nv">filename</span>[,<span class="nv">text</span>]<span class="k">)</span>
</span><span id="__span-52-2"><a id="__codelineno-52-2" name="__codelineno-52-2" href="#__codelineno-52-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">op</span><span class="w"> </span><span class="err">操作</span>
</span><span id="__span-52-3"><a id="__codelineno-52-3" name="__codelineno-52-3" href="#__codelineno-52-3"></a><span class="w">                </span><span class="err">&gt;</span><span class="w"> </span><span class="err">覆盖</span>
</span><span id="__span-52-4"><a id="__codelineno-52-4" name="__codelineno-52-4" href="#__codelineno-52-4"></a><span class="w">                </span><span class="err">&gt;&gt;</span><span class="w"> </span><span class="err">追加</span>
</span><span id="__span-52-5"><a id="__codelineno-52-5" name="__codelineno-52-5" href="#__codelineno-52-5"></a><span class="w">                </span><span class="err">&lt;</span><span class="w"> </span><span class="err">读</span>
</span><span id="__span-52-6"><a id="__codelineno-52-6" name="__codelineno-52-6" href="#__codelineno-52-6"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">filename</span><span class="w"> </span><span class="err">需要操作的文件名</span>
</span><span id="__span-52-7"><a id="__codelineno-52-7" name="__codelineno-52-7" href="#__codelineno-52-7"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">text</span><span class="w"> </span><span class="err">写入的文本内容，读取是不需要这个参数</span>
</span><span id="__span-52-8"><a id="__codelineno-52-8" name="__codelineno-52-8" href="#__codelineno-52-8"></a>
</span><span id="__span-52-9"><a id="__codelineno-52-9" name="__codelineno-52-9" href="#__codelineno-52-9"></a>
</span><span id="__span-52-10"><a id="__codelineno-52-10" name="__codelineno-52-10" href="#__codelineno-52-10"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>src/hello.cpp<span class="w"> </span>main.cpp<span class="w"> </span>hello.o<span class="w"> </span>hello.hpp<span class="w"> </span>hello
</span><span id="__span-52-11"><a id="__codelineno-52-11" name="__codelineno-52-11" href="#__codelineno-52-11"></a><span class="nv">write</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>file<span class="w"> </span>&gt;<span class="w"> </span>makewrite.txt,<span class="k">$(</span>files<span class="k">))</span>
</span><span id="__span-52-12"><a id="__codelineno-52-12" name="__codelineno-52-12" href="#__codelineno-52-12"></a><span class="nv">read</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>file<span class="w"> </span>&lt;<span class="w"> </span>makewrite.txt<span class="k">)</span>
</span></code></pre></div>
<h3 id="foreach">foreach<a class="headerlink" href="#foreach" title="Permanent link">&para;</a></h3>
<p>对一列用空格隔开的字符序列中每一项进行处理，并返回处理后的列表</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-53-1"><a id="__codelineno-53-1" name="__codelineno-53-1" href="#__codelineno-53-1"></a><span class="k">$(</span><span class="nv">foreach</span> <span class="nv">each</span>,<span class="nv">list</span>,<span class="nv">process</span><span class="k">)</span>
</span><span id="__span-53-2"><a id="__codelineno-53-2" name="__codelineno-53-2" href="#__codelineno-53-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">each</span><span class="w"> </span><span class="err">list中的每一项</span>
</span><span id="__span-53-3"><a id="__codelineno-53-3" name="__codelineno-53-3" href="#__codelineno-53-3"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">list</span><span class="w"> </span><span class="err">需要处理的字符串序列，用空格隔开</span>
</span><span id="__span-53-4"><a id="__codelineno-53-4" name="__codelineno-53-4" href="#__codelineno-53-4"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">process</span><span class="w"> </span><span class="err">需要对每一项进行的处理</span>
</span><span id="__span-53-5"><a id="__codelineno-53-5" name="__codelineno-53-5" href="#__codelineno-53-5"></a>
</span><span id="__span-53-6"><a id="__codelineno-53-6" name="__codelineno-53-6" href="#__codelineno-53-6"></a><span class="nv">list</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="m">2</span><span class="w"> </span><span class="m">3</span><span class="w"> </span><span class="m">4</span><span class="w"> </span><span class="m">5</span>
</span><span id="__span-53-7"><a id="__codelineno-53-7" name="__codelineno-53-7" href="#__codelineno-53-7"></a><span class="nv">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>foreach<span class="w"> </span>each,<span class="k">$(</span>list<span class="k">)</span>,<span class="k">$(</span>addprefix<span class="w"> </span>cpp,<span class="k">$(</span>addsuffix<span class="w"> </span>.cpp,<span class="k">$(</span>each<span class="k">))))</span>
</span></code></pre></div>
<p>作用类似C/C++中的循环</p>
<div class="language-c++ highlight"><pre><span></span><code><span id="__span-54-1"><a id="__codelineno-54-1" name="__codelineno-54-1" href="#__codelineno-54-1"></a><span class="kt">int</span><span class="w"> </span><span class="n">list</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">};</span>
</span><span id="__span-54-2"><a id="__codelineno-54-2" name="__codelineno-54-2" href="#__codelineno-54-2"></a><span class="kt">int</span><span class="w"> </span><span class="n">result</span><span class="p">[</span><span class="mi">5</span><span class="p">];</span>
</span><span id="__span-54-3"><a id="__codelineno-54-3" name="__codelineno-54-3" href="#__codelineno-54-3"></a><span class="kt">int</span><span class="w"> </span><span class="n">each</span><span class="p">;</span>
</span><span id="__span-54-4"><a id="__codelineno-54-4" name="__codelineno-54-4" href="#__codelineno-54-4"></a><span class="k">for</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">5</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span>
</span><span id="__span-54-5"><a id="__codelineno-54-5" name="__codelineno-54-5" href="#__codelineno-54-5"></a><span class="p">{</span>
</span><span id="__span-54-6"><a id="__codelineno-54-6" name="__codelineno-54-6" href="#__codelineno-54-6"></a><span class="w">    </span><span class="n">each</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
</span><span id="__span-54-7"><a id="__codelineno-54-7" name="__codelineno-54-7" href="#__codelineno-54-7"></a><span class="w">    </span><span class="n">result</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">process</span><span class="p">(</span><span class="n">each</span><span class="p">);</span>
</span><span id="__span-54-8"><a id="__codelineno-54-8" name="__codelineno-54-8" href="#__codelineno-54-8"></a><span class="p">}</span>
</span><span id="__span-54-9"><a id="__codelineno-54-9" name="__codelineno-54-9" href="#__codelineno-54-9"></a><span class="c1">// 此时result即为返回结果</span>
</span></code></pre></div>
<h3 id="call">call<a class="headerlink" href="#call" title="Permanent link">&para;</a></h3>
<p>将一些复杂的表达式写成一个变量，用call可以像调用函数一样进行调用。类似于编程语言中的自定义函数。在函数中可以用$(n)来访问第n个参数</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-55-1"><a id="__codelineno-55-1" name="__codelineno-55-1" href="#__codelineno-55-1"></a><span class="k">$(</span><span class="nv">call</span> <span class="nv">funcname</span>,<span class="nv">param1</span>,<span class="nv">param2</span>,…<span class="k">)</span>
</span><span id="__span-55-2"><a id="__codelineno-55-2" name="__codelineno-55-2" href="#__codelineno-55-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">funcname</span><span class="w"> </span><span class="err">自定义函数（变量名）</span>
</span><span id="__span-55-3"><a id="__codelineno-55-3" name="__codelineno-55-3" href="#__codelineno-55-3"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">参数至少一个，可以有多个，用逗号隔开</span>
</span><span id="__span-55-4"><a id="__codelineno-55-4" name="__codelineno-55-4" href="#__codelineno-55-4"></a>
</span><span id="__span-55-5"><a id="__codelineno-55-5" name="__codelineno-55-5" href="#__codelineno-55-5"></a><span class="nv">dirof</span><span class="w"> </span><span class="o">=</span><span class="w">  </span><span class="k">$(</span>dir<span class="w"> </span><span class="k">$(</span>realpath<span class="w"> </span><span class="k">$(</span><span class="m">1</span><span class="k">)))</span><span class="w"> </span><span class="k">$(</span>dir<span class="w"> </span><span class="k">$(</span>realpath<span class="w"> </span><span class="k">$(</span><span class="m">2</span><span class="k">)))</span>
</span><span id="__span-55-6"><a id="__codelineno-55-6" name="__codelineno-55-6" href="#__codelineno-55-6"></a><span class="nv">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>call<span class="w"> </span>dirof,main.cpp,src/hello.cpp<span class="k">)</span>
</span></code></pre></div>
<h3 id="value">value<a class="headerlink" href="#value" title="Permanent link">&para;</a></h3>
<p>对于不是立即展开的变量，可以查看变量的原始定义；对于立即展开的变量，直接返回变量值</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-56-1"><a id="__codelineno-56-1" name="__codelineno-56-1" href="#__codelineno-56-1"></a><span class="k">$(</span><span class="nv">value</span> <span class="nv">variable</span><span class="k">)</span>
</span><span id="__span-56-2"><a id="__codelineno-56-2" name="__codelineno-56-2" href="#__codelineno-56-2"></a>
</span><span id="__span-56-3"><a id="__codelineno-56-3" name="__codelineno-56-3" href="#__codelineno-56-3"></a><span class="nv">var</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>value<span class="w"> </span><span class="k">function</span><span class="w"> </span><span class="nb">test</span>
</span><span id="__span-56-4"><a id="__codelineno-56-4" name="__codelineno-56-4" href="#__codelineno-56-4"></a><span class="nv">var2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>var<span class="k">)</span>
</span><span id="__span-56-5"><a id="__codelineno-56-5" name="__codelineno-56-5" href="#__codelineno-56-5"></a><span class="nv">var3</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="k">$(</span>var<span class="k">)</span>
</span><span id="__span-56-6"><a id="__codelineno-56-6" name="__codelineno-56-6" href="#__codelineno-56-6"></a><span class="nf">all</span><span class="o">:</span>
</span><span id="__span-56-7"><a id="__codelineno-56-7" name="__codelineno-56-7" href="#__codelineno-56-7"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>value<span class="w"> </span>var2<span class="k">)</span>
</span><span id="__span-56-8"><a id="__codelineno-56-8" name="__codelineno-56-8" href="#__codelineno-56-8"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>value<span class="w"> </span>var3<span class="k">)</span>
</span></code></pre></div>
<h3 id="origin">origin<a class="headerlink" href="#origin" title="Permanent link">&para;</a></h3>
<p>查看一个变量定义来源</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-57-1"><a id="__codelineno-57-1" name="__codelineno-57-1" href="#__codelineno-57-1"></a><span class="k">$(</span><span class="nv">origin</span> <span class="nv">variable</span><span class="k">)</span>
</span><span id="__span-57-2"><a id="__codelineno-57-2" name="__codelineno-57-2" href="#__codelineno-57-2"></a>
</span><span id="__span-57-3"><a id="__codelineno-57-3" name="__codelineno-57-3" href="#__codelineno-57-3"></a>
</span><span id="__span-57-4"><a id="__codelineno-57-4" name="__codelineno-57-4" href="#__codelineno-57-4"></a><span class="nv">var2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>origin<span class="w"> </span><span class="k">function</span><span class="w"> </span>
</span><span id="__span-57-5"><a id="__codelineno-57-5" name="__codelineno-57-5" href="#__codelineno-57-5"></a><span class="nf">all</span><span class="o">:</span>
</span><span id="__span-57-6"><a id="__codelineno-57-6" name="__codelineno-57-6" href="#__codelineno-57-6"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>origin<span class="w"> </span>var1<span class="k">)</span><span class="w">    </span><span class="c1"># undefined 未定义</span>
</span><span id="__span-57-7"><a id="__codelineno-57-7" name="__codelineno-57-7" href="#__codelineno-57-7"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>origin<span class="w"> </span>CC<span class="k">)</span><span class="w">        </span><span class="c1"># default 默认变量</span>
</span><span id="__span-57-8"><a id="__codelineno-57-8" name="__codelineno-57-8" href="#__codelineno-57-8"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>origin<span class="w"> </span>JAVA_HOME<span class="k">)</span><span class="w"> </span><span class="c1"># environment 环境变量</span>
</span><span id="__span-57-9"><a id="__codelineno-57-9" name="__codelineno-57-9" href="#__codelineno-57-9"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>origin<span class="w"> </span>var2<span class="k">)</span><span class="w">    </span><span class="c1"># file 在Makefile文件中定义的变量</span>
</span><span id="__span-57-10"><a id="__codelineno-57-10" name="__codelineno-57-10" href="#__codelineno-57-10"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>origin<span class="w"> </span>@<span class="k">)</span><span class="w">        </span><span class="c1"># automatic 自动变量</span>
</span></code></pre></div>
<h3 id="flavor">flavor<a class="headerlink" href="#flavor" title="Permanent link">&para;</a></h3>
<p>查看一个变量的赋值方式</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-58-1"><a id="__codelineno-58-1" name="__codelineno-58-1" href="#__codelineno-58-1"></a><span class="k">$(</span><span class="nv">flavor</span> <span class="nv">variable</span><span class="k">)</span>
</span><span id="__span-58-2"><a id="__codelineno-58-2" name="__codelineno-58-2" href="#__codelineno-58-2"></a>
</span><span id="__span-58-3"><a id="__codelineno-58-3" name="__codelineno-58-3" href="#__codelineno-58-3"></a><span class="nv">var2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>flavor<span class="w"> </span><span class="k">function</span>
</span><span id="__span-58-4"><a id="__codelineno-58-4" name="__codelineno-58-4" href="#__codelineno-58-4"></a><span class="nv">var3</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span>flavor<span class="w"> </span>funciton
</span><span id="__span-58-5"><a id="__codelineno-58-5" name="__codelineno-58-5" href="#__codelineno-58-5"></a><span class="nf">all</span><span class="o">:</span>
</span><span id="__span-58-6"><a id="__codelineno-58-6" name="__codelineno-58-6" href="#__codelineno-58-6"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>flavor<span class="w"> </span>var1<span class="k">)</span><span class="w">    </span><span class="c1"># undefined 未定义</span>
</span><span id="__span-58-7"><a id="__codelineno-58-7" name="__codelineno-58-7" href="#__codelineno-58-7"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>flavor<span class="w"> </span>var2<span class="k">)</span><span class="w">    </span><span class="c1"># recursive 递归展开赋值</span>
</span><span id="__span-58-8"><a id="__codelineno-58-8" name="__codelineno-58-8" href="#__codelineno-58-8"></a><span class="w">    </span>@echo<span class="w"> </span><span class="k">$(</span>flavor<span class="w"> </span>var3<span class="k">)</span><span class="w">    </span><span class="c1"># simple 简单赋值</span>
</span></code></pre></div>
<h3 id="eval">eval<a class="headerlink" href="#eval" title="Permanent link">&para;</a></h3>
<p>可以将一段文本生成Makefile的内容</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-59-1"><a id="__codelineno-59-1" name="__codelineno-59-1" href="#__codelineno-59-1"></a><span class="k">$(</span><span class="nv">eval</span> <span class="nv">text</span><span class="k">)</span>
</span><span id="__span-59-2"><a id="__codelineno-59-2" name="__codelineno-59-2" href="#__codelineno-59-2"></a>
</span><span id="__span-59-3"><a id="__codelineno-59-3" name="__codelineno-59-3" href="#__codelineno-59-3"></a><span class="cp">define eval_target = </span>
</span><span id="__span-59-4"><a id="__codelineno-59-4" name="__codelineno-59-4" href="#__codelineno-59-4"></a><span class="nf">eval</span><span class="o">:</span>
</span><span id="__span-59-5"><a id="__codelineno-59-5" name="__codelineno-59-5" href="#__codelineno-59-5"></a><span class="w">    </span>@echo<span class="w"> </span>Target<span class="w"> </span>Eval<span class="w"> </span>Test
</span><span id="__span-59-6"><a id="__codelineno-59-6" name="__codelineno-59-6" href="#__codelineno-59-6"></a><span class="cp">endef</span>
</span><span id="__span-59-7"><a id="__codelineno-59-7" name="__codelineno-59-7" href="#__codelineno-59-7"></a>
</span><span id="__span-59-8"><a id="__codelineno-59-8" name="__codelineno-59-8" href="#__codelineno-59-8"></a><span class="k">$(</span><span class="nv">eval</span> <span class="k">$(</span><span class="nv">eval_target</span><span class="k">))</span>
</span></code></pre></div>
<p>以上，运行make时将会执行eval目标</p>
<h3 id="shell_1">shell<a class="headerlink" href="#shell_1" title="Permanent link">&para;</a></h3>
<p>用于执行Shell命令</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-60-1"><a id="__codelineno-60-1" name="__codelineno-60-1" href="#__codelineno-60-1"></a><span class="nv">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span>shell<span class="w"> </span>ls<span class="w"> </span>*.cpp<span class="k">)</span>
</span><span id="__span-60-2"><a id="__codelineno-60-2" name="__codelineno-60-2" href="#__codelineno-60-2"></a><span class="k">$(</span><span class="nv">shell</span> <span class="nv">echo</span> <span class="nv">This</span> <span class="nv">is</span> <span class="nv">from</span> <span class="nv">shell</span> <span class="nv">function</span><span class="k">)</span>
</span></code></pre></div>
<h3 id="let">let<a class="headerlink" href="#let" title="Permanent link">&para;</a></h3>
<p>将一个字符串序列中的项拆开放入多个变量中，并对各个变量进行操作（GNU make 4.4以上版本）</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-61-1"><a id="__codelineno-61-1" name="__codelineno-61-1" href="#__codelineno-61-1"></a><span class="k">$(</span><span class="nv">let</span> <span class="nv">var1</span> [<span class="nv">var2</span> <span class="nv">...</span>],[<span class="nv">list</span>],<span class="nv">proc</span><span class="k">)</span>
</span><span id="__span-61-2"><a id="__codelineno-61-2" name="__codelineno-61-2" href="#__codelineno-61-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">var</span><span class="w"> </span><span class="err">变量，可以有多个，用空格隔开</span>
</span><span id="__span-61-3"><a id="__codelineno-61-3" name="__codelineno-61-3" href="#__codelineno-61-3"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">list</span><span class="w"> </span><span class="err">待处理字符串，各项之间空格隔开</span>
</span><span id="__span-61-4"><a id="__codelineno-61-4" name="__codelineno-61-4" href="#__codelineno-61-4"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">proc</span><span class="w"> </span><span class="err">对变量进行的操作，结果为let的返回值</span>
</span><span id="__span-61-5"><a id="__codelineno-61-5" name="__codelineno-61-5" href="#__codelineno-61-5"></a><span class="w">            </span><span class="err">将list中的值依次一项一项放到var中，如果var的个数多于list项数，那多出来的var是空串。如果</span>
</span><span id="__span-61-6"><a id="__codelineno-61-6" name="__codelineno-61-6" href="#__codelineno-61-6"></a><span class="w">            </span><span class="err">var的个数小于list项数，则先依次把前而的项放入var中，剩下的list所有项都放入最后一个var中</span>
</span><span id="__span-61-7"><a id="__codelineno-61-7" name="__codelineno-61-7" href="#__codelineno-61-7"></a>
</span><span id="__span-61-8"><a id="__codelineno-61-8" name="__codelineno-61-8" href="#__codelineno-61-8"></a>
</span><span id="__span-61-9"><a id="__codelineno-61-9" name="__codelineno-61-9" href="#__codelineno-61-9"></a><span class="nv">list</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>a<span class="w"> </span>b<span class="w"> </span>c<span class="w"> </span>d
</span><span id="__span-61-10"><a id="__codelineno-61-10" name="__codelineno-61-10" href="#__codelineno-61-10"></a><span class="nv">letfirst</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span><span class="nb">let</span><span class="w"> </span>first<span class="w"> </span>second<span class="w"> </span>rest,<span class="k">$(</span>list<span class="k">)</span>,<span class="k">$(</span>first<span class="k">))</span>
</span><span id="__span-61-11"><a id="__codelineno-61-11" name="__codelineno-61-11" href="#__codelineno-61-11"></a><span class="nv">letrest</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span><span class="nb">let</span><span class="w"> </span>first<span class="w"> </span>second<span class="w"> </span>rest,<span class="k">$(</span>list<span class="k">)</span>,<span class="k">$(</span>rest<span class="k">))</span>
</span><span id="__span-61-12"><a id="__codelineno-61-12" name="__codelineno-61-12" href="#__codelineno-61-12"></a>
</span><span id="__span-61-13"><a id="__codelineno-61-13" name="__codelineno-61-13" href="#__codelineno-61-13"></a>
</span><span id="__span-61-14"><a id="__codelineno-61-14" name="__codelineno-61-14" href="#__codelineno-61-14"></a><span class="c"># 结合call可以对所有项进行递归处理</span>
</span><span id="__span-61-15"><a id="__codelineno-61-15" name="__codelineno-61-15" href="#__codelineno-61-15"></a><span class="nv">reverse</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">$(</span><span class="nb">let</span><span class="w"> </span>first<span class="w"> </span>rest,<span class="k">$(</span><span class="m">1</span><span class="k">)</span>,<span class="k">$(if</span><span class="w"> </span><span class="k">$(</span>rest<span class="k">)</span>,<span class="k">$(</span>call<span class="w"> </span>reverse,<span class="k">$(</span>rest<span class="k">))</span><span class="w"> </span><span class="k">)$(</span>first<span class="k">))</span>
</span><span id="__span-61-16"><a id="__codelineno-61-16" name="__codelineno-61-16" href="#__codelineno-61-16"></a><span class="nf">all</span><span class="o">:</span><span class="w"> </span>; @<span class="n">echo</span> <span class="k">$(</span><span class="nv">call</span> <span class="nv">reverse</span>,<span class="nv">d</span> <span class="nv">c</span> <span class="nv">b</span> <span class="nv">a</span><span class="k">)</span>
</span></code></pre></div>
<h3 id="_19">信息提示函数<a class="headerlink" href="#_19" title="Permanent link">&para;</a></h3>
<h4 id="error">error<a class="headerlink" href="#error" title="Permanent link">&para;</a></h4>
<p>提示错误信息并终止make执行</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-62-1"><a id="__codelineno-62-1" name="__codelineno-62-1" href="#__codelineno-62-1"></a><span class="k">$(</span><span class="nv">error</span> <span class="nv">text</span><span class="k">)</span>
</span><span id="__span-62-2"><a id="__codelineno-62-2" name="__codelineno-62-2" href="#__codelineno-62-2"></a><span class="w">        </span><span class="err">---</span><span class="w"> </span><span class="err">text</span><span class="w"> </span><span class="err">提示信息</span>
</span><span id="__span-62-3"><a id="__codelineno-62-3" name="__codelineno-62-3" href="#__codelineno-62-3"></a>
</span><span id="__span-62-4"><a id="__codelineno-62-4" name="__codelineno-62-4" href="#__codelineno-62-4"></a><span class="nv">EXIT_STATUS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>-1
</span><span id="__span-62-5"><a id="__codelineno-62-5" name="__codelineno-62-5" href="#__codelineno-62-5"></a><span class="cp">ifneq (0, $(EXIT_STATUS))</span>
</span><span id="__span-62-6"><a id="__codelineno-62-6" name="__codelineno-62-6" href="#__codelineno-62-6"></a><span class="w">    </span><span class="k">$(</span>error<span class="w"> </span>An<span class="w"> </span>error<span class="w"> </span>occured!<span class="w"> </span>make<span class="w"> </span>stopped!<span class="k">)</span>
</span><span id="__span-62-7"><a id="__codelineno-62-7" name="__codelineno-62-7" href="#__codelineno-62-7"></a><span class="cp">endif</span>
</span></code></pre></div>
<h4 id="warning">warning<a class="headerlink" href="#warning" title="Permanent link">&para;</a></h4>
<p>提示警告信息，make不会终止</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-63-1"><a id="__codelineno-63-1" name="__codelineno-63-1" href="#__codelineno-63-1"></a><span class="k">$(</span><span class="nv">warning</span> <span class="nv">text</span><span class="k">)</span>
</span><span id="__span-63-2"><a id="__codelineno-63-2" name="__codelineno-63-2" href="#__codelineno-63-2"></a>
</span><span id="__span-63-3"><a id="__codelineno-63-3" name="__codelineno-63-3" href="#__codelineno-63-3"></a><span class="cp">ifneq (0, $(EXIT_STATUS))</span>
</span><span id="__span-63-4"><a id="__codelineno-63-4" name="__codelineno-63-4" href="#__codelineno-63-4"></a><span class="w">    </span><span class="k">$(</span><span class="nv">warning</span> <span class="nv">This</span> <span class="nv">is</span> <span class="nv">a</span> <span class="nv">warning</span> <span class="nv">message</span><span class="k">)</span>
</span><span id="__span-63-5"><a id="__codelineno-63-5" name="__codelineno-63-5" href="#__codelineno-63-5"></a><span class="cp">endif</span>
</span></code></pre></div>
<h4 id="info">info<a class="headerlink" href="#info" title="Permanent link">&para;</a></h4>
<p>输出一些信息</p>
<div class="language-makefile highlight"><pre><span></span><code><span id="__span-64-1"><a id="__codelineno-64-1" name="__codelineno-64-1" href="#__codelineno-64-1"></a><span class="k">$(</span><span class="nv">info</span> <span class="nv">text</span>…<span class="k">)</span>
</span><span id="__span-64-2"><a id="__codelineno-64-2" name="__codelineno-64-2" href="#__codelineno-64-2"></a>
</span><span id="__span-64-3"><a id="__codelineno-64-3" name="__codelineno-64-3" href="#__codelineno-64-3"></a><span class="k">$(</span><span class="nv">info</span> <span class="nv">编译开始.......</span><span class="k">)</span>
</span><span id="__span-64-4"><a id="__codelineno-64-4" name="__codelineno-64-4" href="#__codelineno-64-4"></a><span class="k">$(</span><span class="nv">info</span> <span class="nv">编译结束</span><span class="k">)</span>
</span></code></pre></div>
<h1 id="_20"><a class="headerlink" href="#_20" title="Permanent link">&para;</a></h1>












                
              </article>
            </div>
          
          
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
        </div>
        
          <button type="button" class="md-top md-icon" data-md-component="top" hidden>
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg>
  回到页面顶部
</button>
        
      </main>
      
        <footer class="md-footer">
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
    <div class="md-copyright__highlight">
      Copyright &copy; 2020 - 2025 snqx-lqh
    </div>
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
        <div class="md-social">
  
    
    
    
    
      
      
    
    <a href="https://github.com/snqx-lqh" target="_blank" rel="noopener" title="github.com" class="md-social__link">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg>
    </a>
  
    
    
    
    
      
      
    
    <a href="https://space.bilibili.com/336653490?spm_id_from=333.1007.0.0" target="_blank" rel="noopener" title="space.bilibili.com" class="md-social__link">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M488.6 104.1c16.7 18.1 24.4 39.7 23.3 65.7v202.4c-.4 26.4-9.2 48.1-26.5 65.1-17.2 17-39.1 25.9-65.5 26.7H92.02c-26.45-.8-48.21-9.8-65.28-27.2C9.682 419.4.767 396.5 0 368.2V169.8c.767-26 9.682-47.6 26.74-65.7C43.81 87.75 65.57 78.77 92.02 78h29.38L96.05 52.19c-5.75-5.73-8.63-13-8.63-21.79 0-8.8 2.88-16.06 8.63-21.797C101.8 2.868 109.1 0 117.9 0q13.2 0 21.9 8.603L213.1 78h88l74.5-69.397C381.7 2.868 389.2 0 398 0q13.2 0 21.9 8.603c5.7 5.737 8.6 12.997 8.6 21.797 0 8.79-2.9 16.06-8.6 21.79L394.6 78h29.3c26.4.77 48 9.75 64.7 26.1m-38.8 69.7c-.4-9.6-3.7-17.4-10.7-23.5-5.2-6.1-14-9.4-22.7-9.8H96.05c-9.59.4-17.45 3.7-23.58 9.8-6.14 6.1-9.4 13.9-9.78 23.5v194.4c0 9.2 3.26 17 9.78 23.5s14.38 9.8 23.58 9.8H416.4c9.2 0 17-3.3 23.3-9.8s9.7-14.3 10.1-23.5zm-264.3 42.7c6.3 6.3 9.7 14.1 10.1 23.2V273c-.4 9.2-3.7 16.9-9.8 23.2-6.2 6.3-14 9.5-23.6 9.5s-17.5-3.2-23.6-9.5-9.4-14-9.8-23.2v-33.3c.4-9.1 3.8-16.9 10.1-23.2s13.2-9.6 23.3-10c9.2.4 17 3.7 23.3 10m191.5 0c6.3 6.3 9.7 14.1 10.1 23.2V273c-.4 9.2-3.7 16.9-9.8 23.2s-14 9.5-23.6 9.5-17.4-3.2-23.6-9.5c-7-6.3-9.4-14-9.7-23.2v-33.3c.3-9.1 3.7-16.9 10-23.2s14.1-9.6 23.3-10c9.2.4 17 3.7 23.3 10"/></svg>
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    
    
    <script id="__config" type="application/json">{"base": "../../..", "features": ["navigation.tracking", "navigation.tabs", "navigation.tabs.sticky", "navigation.expand", "navigation.path", "navigation.prune", "navigation.indexes", "navigation.top", "toc.follow", "search.suggest", "search.highlight", "search.share", "announce.dismiss", "content.code.copy"], "search": "../../../assets/javascripts/workers/search.f8cc74c7.min.js", "translations": {"clipboard.copied": "\u5df2\u590d\u5236", "clipboard.copy": "\u590d\u5236", "search.result.more.one": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.more.other": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 # \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.none": "\u6ca1\u6709\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.one": "\u627e\u5230 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.other": "# \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.placeholder": "\u952e\u5165\u4ee5\u5f00\u59cb\u641c\u7d22", "search.result.term.missing": "\u7f3a\u5c11", "select.version": "\u9009\u62e9\u5f53\u524d\u7248\u672c"}}</script>
    
    
  
      <script src="../../../assets/javascripts/bundle.f1b6f286.min.js"></script>
      
    
  <script src="../../../assets/javascripts/custom.00e08f28.min.js"></script>

  <script id="init-glightbox">const lightbox = GLightbox({"touchNavigation": true, "loop": false, "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom", "slideEffect": "slide"});
document$.subscribe(() => { lightbox.reload() });
</script></body>
</html>